I have this problem, I have
private ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
and a task that is created every 50 milliseconds:
executor.scheduleAtFixedRate(myTask, 0, 50, TimeUnit.MILLISECONDS);
myTask sometimes takes some time (for example, 2-3 seconds or so), but newSingleThreadScheduledExecutor ensures that the next scheduled myTask will wait for the current to complete.
However, I get this error from time to time:
execute: java.util.concurrent.RejectedExecutionException
What should I do? Thanks
java multithreading concurrency exception executor
Andrey
source share