public class demo05 {标签:tickets,JAVA,Thread,tw,start,new,多线程,public,火车票 From: https://www.cnblogs.com/txa2003/p/16953914.html
public static void main(String[] args) {
TicketWindow tw = new TicketWindow();
new Thread(tw,"窗口1").start();
new Thread(tw,"窗口2").start();
new Thread(tw,"窗口3").start();
new Thread(tw,"窗口4").start();
}
}
class TicketWindow2 implements Runnable{
private int tickets = 100;
public void run(){
while (true){
if (tickets>0){
Thread th = Thread.currentThread();
String name = th.getName();
System.out.println(name+"正在发售"+tickets--+"张票");
}
}
}
}