class Ticket extends Thread
{
private int tick = 100;
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();
//Ticket t2 = new Ticket();
//Ticket t3 = new Ticket();
//Ticket t4 = new Ticket();
t1.start();
//t2.start();
//t3.start();
//t4.start();
}
}
多线程(二)——通过继承Thread类创建线程
最新推荐文章于 2022-11-08 16:32:32 发布