标签:read private nts runnable main current new new t ble
多线程实例练习卖票
class TicketWindow2 implements Runnable{
private int tickets=100;
public void run();{
while(true){
if(tickets>0){
System.out.println(Thread.currentThread().getName());
}
}
}
}
public calss Example{
public static void main(String args[]){
TicketWindow2 tw=new TicketWindow();
new Thread(tw,“窗口1”).start();
new Thread(tw,“窗口2”).start();
new Thread(tw,“窗口3”).start();
new Thread(tw,“窗口4”).start();
}
}
标签:read private nts runnable main current new new t ble
原文地址:https://blog.51cto.com/14589602/2461516