Solve the problem using Java multithreading

Job ID: 33280006

Budget: $2 – $8 USD

A Hospital department has a Doctor (D) who helps
patients with their Health. The D’s office is rather
small and has room for only one desk with a chair and computer. There are three chairs in
the hallway outside the office where patients can sit and wait if the D is currently
helping another patient. When there are no patients who need help, D sits at the
desk and takes a nap. If a patient arrives and finds the D sleeping, the patient must
awaken the D to ask for help. If a patient arrives and finds the D currently helping
another patient, the patient sits on one of the chairs in the hallway and waits. If no chairs
are available, the patient will come back at a later time. Using threads, implement a
solution that coordinates the activities of the D and the patients. Details for this
assignment are provided below.
The patients and the D
Using threads begin by creating n patients. Each will run as a separate
thread. The D will run as a separate thread as well. patient threads will seek help from
the D. If the D is available, they will obtain help. Otherwise, they will either sit on a
chair in the hallway or, if no chairs are available, will seek help at a later time (random
period of time). If a patient arrives and notices that the D is sleeping, the patient must
notify the D using a semaphore. When the D finishes helping a patient, the D must
check to see if there are patients waiting for help in the hallway. If so, the D must help
each of these patients in turn. If no patients are present, the D may return to napping.
Simulating the D providing help to a patient is to have the appropriate threads sleep for
a random period of time