|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
tylerhayes.tools.TerminationInterceptor
public class TerminationInterceptor
This Class, along with the GracefulShutdown Interface, comprise a simple signal handling mechanism for catching a kill signal--more specifically, when a user hits CTRL-C when running a program through a command-line (won't work when clicking the "Termination" button in Eclipse).
In order to have a kill signal handler, the call to
Runtime.getRuntime().addShutdownHook(Thread) must be given a Thread
object. This object extends Thread and is used as such. It
is only run upon the termination of the program, thus the run()
method's simple call to the shutDown() method of its private
GracefulShutdown Interface instance.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
TerminationInterceptor(GracefulShutdown gracefulShutdown)
Creates a new TerminationInterceptor object with the given GracefulShutdown Interface instance. |
Method Summary | |
---|---|
void |
run()
Calls the object's GracefulShutdown instance's shutDown() method. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, 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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TerminationInterceptor(GracefulShutdown gracefulShutdown)
gracefulShutdown
- Usually an instance of the class that contains the
main method of the program (which has to implement the
GracefulShutdown Interface, of course).Method Detail |
---|
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |