Methods Summary |
---|
private void | ApplicationShutdownHooks()
|
static synchronized void | add(java.lang.Thread hook)
if(hooks == null)
throw new IllegalStateException("Shutdown in progress");
if (hook.isAlive())
throw new IllegalArgumentException("Hook already running");
if (hooks.containsKey(hook))
throw new IllegalArgumentException("Hook previously registered");
hooks.put(hook, hook);
|
static synchronized java.lang.ApplicationShutdownHooks | hook()
if (instance == null)
instance = new ApplicationShutdownHooks();
return instance;
|
static synchronized boolean | remove(java.lang.Thread hook)
if(hooks == null)
throw new IllegalStateException("Shutdown in progress");
if (hook == null)
throw new NullPointerException();
return hooks.remove(hook) != null;
|
public void | run()
Collection<Thread> threads;
synchronized(ApplicationShutdownHooks.class) {
threads = hooks.keySet();
hooks = null;
}
for (Thread hook : threads) {
hook.start();
}
for (Thread hook : threads) {
try {
hook.join();
} catch (InterruptedException x) { }
}
|