How to stop next thread from running in a ScheduledThreadPoolExecutor
I have a ScheduledThreadPoolExecutor which has one thread and runs for every 30 seconds. Now, if the current executing thread throws some exception, then I need to make sure that the next thread do not run and the the ScheduledThreadPoolExecutor is down. How do I achieve this? As a clean way, you can simply use a static accessed class to set/check the execution availability. import java.util.concurrent.atomic.AtomicBoolean; class ThreadManager { private static AtomicBoolean shouldStop = new AtomicBoolean(false); public static void setExceptionThrown(boolean val) { shouldStop.set(val); } public