-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainGUI.java
More file actions
51 lines (27 loc) · 915 Bytes
/
Copy pathMainGUI.java
File metadata and controls
51 lines (27 loc) · 915 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// this will create 2 elevators
import java.util.*;
import java.lang.*;
import java.util.Timer;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;
import java.util.Random;
public class MainGUI{
public static void main(String[] args) throws InterruptedException{
ElevatorControllerGUI elevatorController = new ElevatorControllerGUI();
Elevator elevator = new Elevator(elevatorController);
// start the elevator and wait for request
elevator.start();
// create thread pool
ExecutorService executor = Executors.newFixedThreadPool(5);
// create random people
Person[] people = new Person[5];
for (int i=0; i<5; i++){
people[i] = new Person(elevatorController);
}
for(Person p: people){
executor.submit(p);
}
executor.shutdown();
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.MINUTES);
}
}