Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SimpleRateLimiter {
- private ExecutorService executorService = Executors.newFixedThreadPool(10);
- private static SimpleRateLimiter srl = new SimpleRateLimiter();
- private SimpleRateLimiter() {}
- public static SimpleRateLimiter getInstance() {
- return srl;
- }
- public void doSomething() {
- executorService.submit(new Runnable() {
- @Override
- public void run() {
- // call to 3rd party api
- }
- });
- }
- public void terminate() throws Exception {
- executorService.shutdown();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement