Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a Java concurrent program using semaphores to access a car park with two gates, the park has a maximum capacity of 5 0 0

Implement a Java concurrent program using semaphores to access a car park with two gates, the park has a maximum capacity of 500 cars. The car runnable is given below:
class Car extends Thread{ Tunnel tunnel;
public Car(Tunnel t){
tunnel = t; }
public void run(){ tunnel.enter();
try{//stay in tunnel for random period int t =(int)(Math.random()*5000); Thread.sleep(t+2000);
}
catch(InterruptedException e){} tunnel.leave();
}}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Usability

Authors: Jakob Nielsen, Raluca Budiu

1st Edition

0133122131, 9780133122138

More Books

Students also viewed these Programming questions

Question

i = ( i M ) ( r i M ) = C o v ( R i , R M ) M 2

Answered: 1 week ago

Question

Explain the chemical properties of acids with examples.

Answered: 1 week ago

Question

Write the properties of Group theory.

Answered: 1 week ago