新闻中心

成功案例

Java多线程模仿医院排号叫号体系

发布时间:2022-09-13 13:14:55
浏览:71

  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(); } }

上一篇:一般门诊医疗费将归入医保报销 下一篇:医院运营虚拟仿真决议计划剖析体系
  • 联系我们
  • 地址:山东省济南高新区新泺大街奥盛大厦1号楼12F
  • 北京市丰台区广安路9号国投财富广场4号楼1601室
版权所有:火狐体育官方网站app ICP备123 Copyright © 2014 Msunsoft.com All Right Reserved