freehell

2009年12月22日

Java线程中的资源共享问题

摘要: //ThreadDemo01.java//实现Runnable接口,可以实现资源的共享class Demo implements Runnable{ private int ticket=10; public void fun() { while(this.ticket>0) { System.out.println(Thread.currentThread().getName()+"在运行,开始售票:"+this.ticket--); } } public void run() { this.fun(); }}public class ThreadDemo01 {p 阅读全文

posted @ 2009-12-22 11:00 freehell 阅读(226) 评论(0) 推荐(0) 编辑

导航