java.lang.Object
java.lang.Thread
com.aoapps.concurrent.ExecutorServiceShutdownHook
- All Implemented Interfaces:
Runnable
The threads of executor services can cause a JVM to keep running if they are not
daemon threads. Additionally, daemon threads can be interrupted by an unclean
shutdown if no shutdown hook is provided. By using this implementation of a
shutdown hook you get the best of both - threads stop at the correct time, not
too soon and not too late.
- Author:
- AO Industries, Inc.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorDescriptionExecutorServiceShutdownHook
(ExecutorService executorService) Creates a new shutdown hook.ExecutorServiceShutdownHook
(ExecutorService executorService, long shutdownTimeout, TimeUnit shutdownTimeoutUnit) Creates a new shutdown hook.ExecutorServiceShutdownHook
(ExecutorService executorService, String threadName) Creates a new shutdown hook.ExecutorServiceShutdownHook
(ExecutorService executorService, String threadName, long shutdownTimeout, TimeUnit shutdownTimeoutUnit) Creates a new shutdown hook. -
Method Summary
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
ExecutorServiceShutdownHook
Creates a new shutdown hook. -
ExecutorServiceShutdownHook
public ExecutorServiceShutdownHook(ExecutorService executorService, long shutdownTimeout, TimeUnit shutdownTimeoutUnit) Creates a new shutdown hook. -
ExecutorServiceShutdownHook
Creates a new shutdown hook. -
ExecutorServiceShutdownHook
public ExecutorServiceShutdownHook(ExecutorService executorService, String threadName, long shutdownTimeout, TimeUnit shutdownTimeoutUnit) Creates a new shutdown hook.
-
-
Method Details