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 pedestrianscrossing a weak bridge. If more than 2 pedestrians cross the bridgeat once then the bridge will collapse, your code must prevent this.

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!