class Ticket implements Runnable
{
int ticket=100;
public void run(){
while(true){
if(ticket>0){
i--;
System.out.println(Thread.currentThread().getName()+"..."+ticket);
}
}
}
}
class ThreadDemo3
{
public static void main(String[] args)
{
Ticket t=new Ticket();
Thread t1=new Thread(t);
Thread t2=new Thread(t);
Thread t3=new Thread(t);
Thread t4=new Thread(t);
t1.start();
t2.start();
t3.start();
t4.start();
}
}
为什么运行结果,有两个98而没有99 |
|