Reference no: EM132206587
Write a multithreaded Java program for patient room access control in a hospital. The controller must obey the following simple rules:
1. Doctors can enter the room one at a time, and can enter only if no visitors are in the room.
2. A visitor can only enter the room if no doctors are in the room and if a maximum of 3 other visitors are in the room (four in total).
3. When a doctor arrives, he must wait for all the current visitors in the room to leave the room.
4. When a doctor arrives, no more visitors are allowed in, until a waiting doctor enters and leaves the room.
5. When a doctor leaves the room, only one waiting doctor or up to four waiting visitors can enter the room, depending on who comes first.
You shall do this by creating and synchronizing the following threads:
1. A random number less than 1500 of threads representing visitors who wish to visit the patient in his room.
2. A random number less than 750 of threads representing doctors who want to see the patient in his room.
3. One display thread which watches the room status and periodically prints out the current number of doctors and visitors in the patient room.
Requirements:
• Use a Java monitor for both synchronization and mutual exclusion
• Implement mutual exclusion where appropriate
• Avoid busy-waiting, starvation and deadlocks
• Each doctor and visitor thread must pause for a random period (up to 1s) before entering the room.
• Each doctor and visitor thread must pause for a random period (up to 1s) before exiting the room.
• The display thread shall continue working until it is interrupted by the user.
The output from the display thread must clearly show that your controller is working as specified above. Study the output of your program carefully to check it is operating and synchronizing properly, without any deadlock or starvation.
Product differentiation is essential to the branding process
: Product differentiation is essential to the branding process. In choosing to differentiate a product, a marketer has the choice of form, features,
|
Draw the budget set for the consumer in detail
: There are two perfectly divisible goods. A consumer wants to buy as many units as possible of these two goods. The consumer has an initial wealth w S100.
|
Existing hospital policy involving electronic information
: Find online, one existing hospital policy involving electronic information, EHRs, cut and paste, retention, or any related policy you can find.
|
Find the socially optimal level of emissions
: Consider a good for which production generates external costs. Let the marginal external cost function be MEC=aE, where a is your 1-digit number.
|
Write a multithreaded java program for patient room access
: Write a multithreaded Java program for patient room access control in a hospital.
|
How economists manage the scarcity of resources
: How economists manage the scarcity of resources when there are unlimited demands? How economists solve the problem of scarcity when there are unlimited demands?
|
Alternative hypotheses of difference based on presented
: You will practice creating null and alternative hypotheses of difference based on the presented scenarios.
|
A summary of the rsa public-key encryption algorithm
: In your opinion what needs to be done to help Diffie-Hellman key exchange to stand against the man-in-the-middle attack.
|
How many units of chardonnay is he consuming
: Harold consumes chardonnay and quiche. His utility function is U(c, q) = min{c, q^2}. Draw a diagram showing three or four of Harold's indifference curves.
|