zoukankan      html  css  js  c++  java
  • 看病

    package com.day19;
    
    public class Test {
        public static void main(String[] args) {
            Thread thread = new Thread(new Demo01());
            thread.setPriority(Thread.MAX_PRIORITY);
            thread.start();
            //主线程模拟医院叫号
            for(int i=0;i<20;i++){
                System.out.println("普通号:"+(i+1)+"号病人在看病!");
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }
                if(i==9){
                    try {
                        thread.join();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
    package com.day19;
    
    public class Demo01 implements Runnable {
        public void run() {
            for (int i = 0; i < 10; i++) {
                System.out.println("特需号:"+(i+1)+"号病人在看病!");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }

  • 相关阅读:
    简单状态机
    c语言状态机
    存储公司
    正确跑步
    好好做自己能做的
    I2C学习
    es6 generator函数
    es6 for of 循环
    es6 proxy代理
    es6 Symbol类型
  • 原文地址:https://www.cnblogs.com/zhangbupang/p/11305785.html
Copyright © 2011-2022 走看看