public class Hello extends Thread {
public void run()
{
System.out.println("wait...");
synchronized(this) {
try {
this.wait();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
System.out.println("child");
}
public static void main(String args[]) throws Exception
{
Hello h = new Hello();
h.start();
System.out.println("main");
Thread.sleep(3000);
synchronized(h) {
h.notify();
}
System.out.println("main over");
}
}
阅读(700) | 评论(0) | 转发(0) |