public class JvmShutdownSafeguard extends Thread
When the JVM shuts down cleanly (SIGTERM or System.exit(int)
) it runs
all installed shutdown hooks. It is possible that any of the shutdown hooks blocks,
which causes the JVM to get stuck and not exit at all.
This utility installs a shutdown hook that forcibly terminates the JVM if it is still alive a certain time after clean shutdown was initiated. Even if some shutdown hooks block, the JVM will terminate within a certain time.
Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Modifier and Type | Method and Description |
---|---|
static void |
installAsShutdownHook(org.slf4j.Logger logger)
Installs the safeguard shutdown hook.
|
static void |
installAsShutdownHook(org.slf4j.Logger logger,
long delayMillis)
Installs the safeguard shutdown hook.
|
void |
run() |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public static void installAsShutdownHook(org.slf4j.Logger logger)
logger
- The logger to log errors to.public static void installAsShutdownHook(org.slf4j.Logger logger, long delayMillis)
logger
- The logger to log errors to.delayMillis
- The delay (in milliseconds) to wait after clean shutdown was stared,
before forcibly terminating the JVM.Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.