Question: Complete the following java program using Semaphores. The program simulates pedestrians crossing a weak bridge. If more than 2 pedestrians cross the bridge at once



Complete the following java program using Semaphores. The program simulates pedestrians crossing a weak bridge. If more than 2 pedestrians cross the bridge at once then the bridge will collapse, your code must prevent this. When the pedestrians run they should do so as concurrent threads and should cross the bridge 3 times, the pedestrian should occupy the bridge for 100ms before leaving, import java.util.concurrent. Semaphore; public class Pedestrian extends Thread sateTorosa - private String name, public Pedestrian(String canent) { name - nanen for (int i - 0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
