Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1072899
  • 博文数量: 252
  • 博客积分: 4561
  • 博客等级: 上校
  • 技术积分: 2833
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-15 08:23
文章分类

全部博文(252)

文章存档

2015年(2)

2014年(1)

2013年(1)

2012年(16)

2011年(42)

2010年(67)

2009年(87)

2008年(36)

分类:

2010-03-03 14:34:00

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");
 }
}
阅读(667) | 评论(0) | 转发(0) |
0

上一篇:二分查找法

下一篇:synchronized HashMap

给主人留下些什么吧!~~