package com.shrimpking.t1;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/21 16:57
*/
class TestThread4 extends Thread{
private int tickets = 5;
@Override
public void run(){
while (tickets > 0){
System.out.println(Thread.currentThread().getName() +"出票" + tickets);
tickets -= 1;
}
}
}
//ch15-4 多线程模拟售票
public class ThreadDemo4
{
public static void main(String[] args)
{
TestThread4 th = new TestThread4();
th.start();
th.start();
th.start();
th.start();
}
}
09-28
1
09-28
1
09-22
227