I am using ScheduledExecutorService, and after I call it’s shutdown method, I can’t schedule a Runnable on it. Calling scheduleAtFixedRate(runnable, INITIAL_DELAY, after
INTERVAL, TimeUnit.SECONDS)shutdown() throws java.util.concurrent.RejectedExecutionException. Is there another way to run a new task after shutdown() is called on ScheduledExecutorService?
I am using ScheduledExecutorService , and after I call it’s shutdown method, I can’t
Share
You can reuse the scheduler, but you shouldn’t shutdown it. Rather, cancel the running thread which you can get when invoking scheduleAtFixedRate method. Ex: