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--);
}
}
}
运行结果并没有显示线程共享资源?
|
|