class Demo implements Runnable
{
private int key =100;
public void run()
{ while(true)
{if (key>0)
{
System.out.println(Thread.currentThread().getName()+"::"+key--);
}
}
}
}
class A
{
public static void main(String[] args)
{
Demo d=new Demo();
Thread t1=new Thread(d);
Thread t2=new Thread(d);
Thread t3=new Thread(d);
Thread t4=new Thread(d);
t1.start();
t2.start();
t3.start();
t4.start();
}
}为什么要用while(true)判断正确才能运行呢,不写while为什么就不行了啊? 请大家指教一下 |