import java.lang.Object;
import java.lang.InterruptedException;
/** 
 Class <pre>test</pre>
  Tests some threading stuff.
  @version 1.0
  @author George Cross
*/
public class test{
  
  /** 
    test
    @param none none
    @return nothing
    @exception InteruptedException
  */
  public test() throws InterruptedException {
    //implied super
  }

  /**
    exec  
    @param none none
    @return nothing
    @exception InterruptedException 
  */
  public synchronized void exec() throws InterruptedException {
    test2 t2=new test2(this);
    t2.start();
    wait();
  }

  public static void main (String[] args) throws InterruptedException{
    test t = new test();
    t.exec();
    System.out.println("Hello World!\t" + t);
  }
}

class test2 extends Thread{
  Object obj;
  public test2(Object obj){
    this.obj=obj;
    System.out.println("Hello World from Thread Constructor!\t" + this);
  }
  public void run() {
    System.out.println("Hello World from Thread.run!\t" + this);
    synchronized (obj){
      obj.notify();
      
// Uncomment this below to cause a deadlock
//
//      try {
//        obj.wait();
//      }
//      catch (InterruptedException ie){
//        ie.printStackTrace();
//      }
    }
  }
}
  
