public static class Test1 implements Runnable{
private Test2 test2;
public Test1(){
test2 = new Test2();
(new Thread(test2)).start();
(new Thread(this)).start();
}
public void run(){
try{
Thread.sleep(2000);
synchronized(test2){
test2.notify();
}
}catch(Exception e){
}
}
}
public static class Test2 implements Runnable{
public void run(){
System.out.println("In Test2");
try{
synchronized(this){
this.wait();
}
}catch(Exception e){
e.printStackTrace();
}
System.out.println("Awake");
}
}
public static void main(String[] args){
new Test1();
}