JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* EMERGENCY ROOM */
/* A Hospital Simulation */
/* featuring PriorityBlockingQueue */
/* written by Tibor Santa */
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.List;
import java.util.Random;
public class Hospital {
public static void main(String[] args) {
System.out.println("A new day begins at the hospital!\n");
BlockingQueue<Patient> sharedQueue = new PriorityBlockingQueue<>();
for (String clerk : List.of("Pam Beesley", "Ms Blankenship", "Andy Sachs")) {
new Thread(new ReceptionDesk(sharedQueue, clerk)).start();
}
for (String doc : List.of("Dr House", "Dr Brinkmann", "Dr Mengele")) {
new Thread(new EmergencyRoom(sharedQueue, doc)).start();
}
}
}
/**
* Emergency Severity Index
* @url https://en.wikipedia.org/wiki/Emergency_Severity_Index
*/
enum Severity {
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run