Methods Summary |
---|
public java.lang.Thread | getShutdownHook()
return new TestProcessShutdownHook();
|
public static void | main(java.lang.String[] args)
TestProcess tp = new TestProcess();
new Thread(tp, "TestProcess thread").start();
Runtime.getRuntime().addShutdownHook(tp.getShutdownHook());
|
public void | run()
for (int i = 0; i < 5 && run; i++)
{
System.out.println(Thread.currentThread().getName());
try { Thread.sleep(2000); } catch (InterruptedException ie) {}
}
synchronized(this)
{
done = true;
notifyAll();
}
|
public void | shutdown()
if (!done)
{
System.out.println("shutting down TestProcess");
run = false;
synchronized(this)
{
while (!done)
{
try { wait(); } catch (InterruptedException ie) {}
}
}
System.out.println("TestProcess shut down");
}
|