22 lines
377 B
Java
22 lines
377 B
Java
package semaphore;
|
|
|
|
public class ValetSimulation implements Runnable {
|
|
private final Queue<Car> valetQueue;
|
|
|
|
public ValetSimulation(Queue<Car> valetQueue) {
|
|
this.valetQueue = valetQueue;
|
|
}
|
|
|
|
public void run() {
|
|
while (true) {
|
|
try {
|
|
Car car = valetQueue.take();
|
|
car.park();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
System.exit(1);
|
|
}
|
|
}
|
|
}
|
|
}
|