/*
需求:简单的卖票程序
多个窗口卖票。
想在最后实现 打印ticket over ,有什么好的方法么?越多越好!!
*/
class Ticket extends Thread
{
private static int tick = 88;
Ticket(String name)
{
super(name);
}
public void run()
{
while (true)
{
if(tick>0)
{
System.out.println(Thread.currentThread().getName()+"sale:"+tick--);
}
}
}
}
class TicketDemo
{
public static void main(String[] args)
{
Ticket t1 = new Ticket("oneWindow");
Ticket t2 = new Ticket("twoWindow");
Ticket t4 = new Ticket("threeWindow");
Ticket t3 = new Ticket("fourWindow");
Ticket t5 = new Ticket("fiveWindow");
t1.start();
t2.start();
t4.start();
t5.start();
t3.start();
System.out.println("ticket over");//想在语句最后实现这句话,该怎么做啊?
}
}
|