I'm a newbie programmer who's grappling with this issue of ScheduledThreadPoolExecutor.
Upon some googling I got to know how to handle the exceptions from Runnable() part by using afterExecute method. Now it boils to down to this.
What if the ScheduledThreadPoolExecutor's scheduleAtFixedRate() method breaks out an error and the thread stops all of the sudden?
In other words, what if the error is from the Executor class and not from the Runnable implementation?
Is there any way that I can catch errors && deal with it (by restarting the whole scheduling) ?
Thank you
The error does not come from the executor class.
Yes you can use different techniques to recognize an error and restart
ScheduledExecutorService
, but the real question should be: is that the right thing to do ?If you can deal with the error in your Runnable, better deal with it there instead of paying the toll of restarting an Executor.