黑马程序员技术交流社区

标题: 线程运行没有显示共享资源? [打印本页]

作者: 范鹏霄    时间: 2014-9-2 21:32
标题: 线程运行没有显示共享资源?
public class Hello
{
public static void main(String args[])
{
                TestThread t=new TestThread();
                new Thread(t).start();
                new Thread(t).start();       
}
}
class TestThread implements Runnable
{
public void run()
{
        int tickets=10;
        while(true)
         {
        if(tickets>0)
                System.out.println(Thread.currentThread().getName()+"出售"+tickets--);
         }
}
}
运行结果并没有显示线程共享资源?








欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2