org.intermine.util
Class ShutdownHook

java.lang.Object
  extended by java.lang.Thread
      extended by org.intermine.util.ShutdownHook
All Implemented Interfaces:
java.lang.Runnable

public final class ShutdownHook
extends java.lang.Thread

This class provides a "shutdown" service to other classes. It sets up a single shutdown hook, which iterates through a series of objects that are registered with it, shutting them down in turn. This class currently supports java.io.Writer, java.io.OutputStream, and ObjectStoreWriterInterMineImpl. It allows objects to be wrapped in a WeakReference, so that the shutdown hook does not preclude those objects from being garbage collected. The objects are shut down in the opposite order to them being added to this ShutdownHook. Therefore, if you register objects to be shut down from the constructor, no object will be shut down before another object that relies on it for its own shutdown.


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
 
Method Summary
static void registerObject(java.lang.Object object)
          Registers an object with the shutdown hook.
 void run()
           
 
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
 

Method Detail

registerObject

public static void registerObject(java.lang.Object object)
Registers an object with the shutdown hook.

Parameters:
object - the object

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread
See Also:
Thread.run()