public abstract class ShutdownHookBase
extends java.lang.Thread
setRegularShutdownExpected() before regularly exiting the JVM,
as otherwise interruptDetected() would be called erroneously.
Recommended reading: http://www-106.ibm.com/developerworks/ibm/library/i-signalhandling/
(also talks about signals for tougher mishaps than Ctrl-c).
See also Runtime.addShutdownHook(Thread)
Abstracted from the java container's shutdown hook, to simplify registering such hooks also in jlog etc.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.logging.Logger |
logger |
protected boolean |
m_regularShutdownExpected |
protected java.lang.String |
processName |
| Constructor and Description |
|---|
ShutdownHookBase(java.util.logging.Logger logger,
java.lang.String processName) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
interruptDetected()
Is called when the JVM is about to terminate due to an interrupt signal.
|
protected void |
regularTermination()
Subclasses can override this method to log nothing or something else.
|
void |
run() |
void |
setRegularShutdownExpected()
Must be called right before the program ends.
|
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, yieldprotected volatile boolean m_regularShutdownExpected
protected final java.util.logging.Logger logger
protected final java.lang.String processName
public ShutdownHookBase(java.util.logging.Logger logger,
java.lang.String processName)
logger - The logger to be used by this object.processName - Used as the thread name, with "ShutdownHook" appended.public void run()
run in interface java.lang.Runnablerun in class java.lang.ThreadRunnable.run()protected void regularTermination()
protected abstract void interruptDetected()
public void setRegularShutdownExpected()