-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParking.java
More file actions
29 lines (22 loc) · 772 Bytes
/
Parking.java
File metadata and controls
29 lines (22 loc) · 772 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
public class Parking {
public static int numPlaces;
/*Thread Counter*/
private final int numCars;
public Parking(int numPlaces, int numCars) {
Parking.numPlaces = numPlaces;
this.numCars = numCars;
}
public void startThreads() {
ParkingChecker cObj = new ParkingChecker();
/*Initialized a new array and a new one to store the slots*/
cObj.iniArray();
CarThread[] aCar = new CarThread[numCars];
for (int i = 0; i < numCars; i++) {
/* Store the new registered slots in the CarThread object*/
aCar[i] = new CarThread("C" + i, cObj);
}
for (CarThread carThread : aCar) {
carThread.start();
}
}
}