How to control/limit the tasks that are submitted to a ExecutorService? I have SMSTask
that sends SMS messages and I need to control the executor so that it can onl
Try RateLimiter from Guava. You must share one instance between all tasks running in the pool:
final RateLimiter rateLimiter = RateLimiter.create(N)
//and in your task:
rateLimiter.tryAcquire();
sendSms();
tryAcquire();
will block for the amount of time precisely to preserve N
frequency.