Suppose I have a task that is pulling elements from a java.util.concurrent.BlockingQueue and processing them.
public void scheduleTask(int delay, TimeUnit timeUnit)
{
scheduledExecutorService.scheduleWithFixedDelay(new Task(queue), 0, delay, timeUnit);
}
How can I schedule / reschedule the task if the frequency can be changed dynamically?
I don't think you can change a fixed rate delay. I think you need to use schedule() to perform a one-shot, and schedule again once that has completed (with a modified time out if required).