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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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