class Test extends Thread
{
private static int num=100;
public void run()
{
while(true)
{
if (num>0)
{
/*
try
{
sleep(10);
}
catch (Exception e)
{
}*/
System.out.println("第"+Thread.currentThread().getName()+"个线程"+ num--);
}
}
}
}
class ThreadDemo
{
public static void main(String[] args)
{
Test t1=new Test();
Test t2=new Test();
t1.start();
t2.start();
}
}
我这个怎么会出现死锁啊???郁闷死了
|
|