Write a multithreaded java program for patient room access

Assignment Help Computer Engineering
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.

Reference no: EM132206587

Questions Cloud

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.

Reviews

Write a Review

Computer Engineering Questions & Answers

  What is your obligation now

should you have been doing the scan in the first place? Why or why not? Second, what is your obligation now that you have discovered issues?

  Draw one convex-to-the-origin production isoquant

In discussing appropriate technology for less-developed nations, we noted that given the relative labor abundance and relatively lower wages in the less-develop

  Describe the role of application service providers

Describe the role of application service providers (ASPs) in obtaining new systems. What are their advantages and disadvantages?

  Design the necessary logic interface to make peripheral look

Suppose you have to use a non-68000-series peripheral that signals an interrupt by asserting a single active-low IRQ* output.

  Write dpwn an algorithm, using pseudo code

Write down an algorithm, using pseudo code, "Consensus algorithm": A group of ten people want to decide which one flavor of ice cream they will all order, out of three options.

  Define restricted telephone switching system

Construct a finite-state machine for a restricted telephone switching system that implements these rules. Only calls to the telephone numbers 0, 911.

  Exchange knights in the minimum number of turns

On a 3 x 4 chessboard there are 3 black knights (B B B) and three white knights (W W W). Exchange knights in the minimum number of turns.

  Determine the duties of the system administrator

Determine the duties of the system administrator. Explain the differences between the system administrator and the network administrator.

  Find the output and next state sequence

For the flow table shown below: Find the output and next state sequence for the input sequence.

  Discuss about the destruction of data and information

Using at least 500 words - summarize the article you have chosen. You will be graded on Content/Subject Knowledge, Critical Thinking Skills.

  Propose a relational database design

Propose a relational database design (a set of relation schemata) for the online food ordering and delivery application illustrated in this UML class diagram.

  Define the way in which a person writes or sends e-mails

explain a scenario in which someone displayed bad netiquette. How did someone react to receiving the email? what could the sender have done differently to display good netiquette.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd