package J20250730.demo07_sellTicket;

/**
 * @author WanJl
 * @version 1.0
 * @title SellTicket
 * @description
 * @create 2025/7/30
 */
public class SellTicket implements Runnable{
    //总共100张票
    private int tickets = 100;
    @Override
    public void run() {
        while (true){
            if (tickets>0){
                //出票过程睡10毫秒
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                //显示XX窗口成功售票
                System.out.println(Thread.currentThread().getName()+"售票1张，还剩"+ --tickets+"张票");
            }
        }
    }
}
