package J20250801.homework.demo01;

/**
 * @author WanJl
 * @version 1.0
 * @title Main
 * @description 主程序--测试
 * @create 2025/8/1
 */
public class Main {
    public static void main(String[] args) throws InterruptedException {
        OrderQueue queue=new OrderQueue();
        //3个商家
        Thread rest1=new Thread(new Restaurant(queue,"吴AA"));
        Thread rest2=new Thread(new Restaurant(queue,"赵BB"));
        //Thread rest3=new Thread(new Restaurant(queue,"王CC"));
        //2个骑手
        Thread rider1=new Thread(new Rider(queue,"李11"));
        Thread rider2=new Thread(new Rider(queue,"张22"));

        //启动所有线程
        rest1.start();
        rest2.start();
        //rest3.start();
        rider1.start();
        rider2.start();

        //运行50秒后终止
        Thread.sleep(50000);

        //中断所有线程
        rest1.interrupt();
        rest2.interrupt();
        //rest3.interrupt();
        rider1.interrupt();
        rider2.interrupt();

        System.out.println("系统运行结束，剩余未处理订单："+queue.size());



    }
}
