class Ticket implements Runnable
{
private int tick = 100;
public void run()
{
while(true)
{
if(tick>0)
{
System.out.printlm(Thread.currentThread().getName()+"....sales"+tick--);
}
}
}
}
class TicketDemo
{
public static void main(String[] args)
{
Ticket t = new Ticket();
Thread t1 = new Ticket(t);
Thread t2 = new Ticket(t);
Thread t3 = new Ticket(t);
Thread t4 = new Ticket(t);
t1.start();
t2.start();
t3.start();
t4.start();
}
}
|