package ThreadInterCommunication; import java.util.ArrayList; public class CallOrder2 { private static volatile int count 1; private static volatile ArrayListInteger al new ArrayListInteger(); public static void main(String[] args) { Thread addOrder new Thread(() - { while (1 0) { try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (al.size() 11) { System.out.println(count 号,进入排队状况); // System.out.println(al); al.add(count); count count 1; } } }); Thread delOrder1 new Thread(() - { while (1 0) { try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (al.size() 0) { // System.out.println(count); // System.out.println(al); System.out.println(请第 al.remove(0) 号去诊室1就诊); // count count 1; } } }); Thread delOrder2 new Thread(() - { while (1 0) { try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (al.size() 0) { // System.out.println(count); // System.out.println(al); System.out.println(请第 al.remove(0) 号去诊室2就诊); // count count 1; } } }); addOrder.start(); try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } delOrder1.start(); try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } delOrder2.start(); } }
上一篇:一般门诊医疗费将归入医保报销 下一篇:医院运营虚拟仿真决议计划剖析体系