PLEASE PROVIDE A JAVA PROGRAM:
A university wants to demonstrate its political correctness by applying the Supreme Court's "Separate but equal is inherently unequal" doctrine to gender as well as race. As such, it has decided that both genders will use the same bathroom facilities. In order to preserve some tradition, however, it decrees that when a woman is in the bathroom, only other women may enter, and when a man is in the bathroom, only other men may enter. Each politically correct bathroom will have a sign on the outside indicating what state the bathroom is in; Empty, Women Present, or Men Present.
Design and develop this multi-threaded application that will simulate the usage of the bathroom according to the rules laid out by university. A status report should be available whenever anyone enters or leaves the bathroom which should include the gender of the person entering or leaving, the state of the bathroom, the number of men and/or women waiting, and number of occupants inside, and the gender of the occupants currently in the bathroom.
he following classes should be implemented:
- PCB Class
- This class really does all the work of synchronizing access to the PCB. The PCB has a state, which reflects whether it is empty, or whether there are males or females inside. It also must keep track of the number of occupants which are inside, and the number that are waiting to get inside. There can be males or females inside or waiting. The PCB must have a mean of blocking the thread which is trying to gain access if the state of the PCB does not permit access (i.e., when occupants are females, and males are trying to get access). There should be a maleEnters( ) method and a femaleEnters( ) method. These methods check the state to see whether the male or female thread is allowed to enter or must be blocked. Also, there should be a femaleExits( ) method and a maleExits( ) method. These methods update the counter and state member variables appropriately.
- MaleThread and FemaleThread Classes
- These classes contain the code that simulates the actions of a male or female thread entering and exiting the PCB. These two classes can either inherit from the Thread class or implement the Runnable interface. The constructor for these two classes should accept a PCB object so that all the male and female threads are using the same PCB object.
- Main Test Program
- This program controls the simulation. It must have a PCB object to be used by the male and female threads.
Recently Asked Questions
- Discuss 2 of the 3 measures to guard against social loafing. Use examples from past or present learning team experiences to explain these measures.
- Helo, I am needing help with my assignment write up 1 for BIS 340 from ASU. If someone could get back to me on how to go about tackling this project that would
- Please refer to the attachment to answer this question. This question was created from I See the Light. Additional comments: "Can you please show me where did