FileDocCategorySizeDatePackage
TestProcess.javaAPI DocApache Ant 1.702257Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.taskdefs

TestProcess

public class TestProcess extends Object implements Runnable
Interactive Testcase for Processdestroyer.

Fields Summary
private boolean
run
private boolean
done
Constructors Summary
Methods Summary
public java.lang.ThreadgetShutdownHook()

        return new TestProcessShutdownHook();
    
public static voidmain(java.lang.String[] args)

        TestProcess tp = new TestProcess();
        new Thread(tp, "TestProcess thread").start();
        Runtime.getRuntime().addShutdownHook(tp.getShutdownHook());
    
public voidrun()

        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 voidshutdown()


      
    
        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");
        }