最后要crtl+c强制结束才结束,上下滚动鼠标主机都哔哔报警了,是差了什么吗?
class Test
{
public static void main(String[] args)
{
Ticket t = new Ticket();
new Thread(t).start();
new Thread(t).start();
new Thread(t).start();
new Thread(t).start();
}
}
class Ticket implements Runnable
{
private int ticket = 100;
public void run()
{
while(true)
{
if(ticket>0)
System.out.println(Thread.currentThread().getName()+"....sale..."+ticket--);
}
}
}
|