Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For health reasons, we need to control the number of persons that can be simultaneously in a room. We distinguish persons who are vaccinated and

For health reasons, we need to control the number of persons that can be simultaneously in a room. We distinguish persons who are vaccinated and those who are not.

Question II [50 points] java

  1. Write a class SharedRoom. It has :
    • 2 shared counters (countVacc and countNotVacc) initialized to 0. (use static)
    • A static method print that prints the values of the two counters
  2. Write a Thread class Vaccinated. The main work of Vaccinated (the run method) is:
    • Enter in the SharedRoom (increment the number of vaccinated in the room)
    • Print the count of vaccinated and not vaccinated in the room
    • Stay in the room for 5 seconds (sleep for 5 seconds)
    • Leave the SharedRoom (decrement the number of vaccinated in the room)
  3. Write a Thread class NotVaccinated. The main work of NotVaccinated is:
    • Enter in the SharedRoom (increment the number of not vaccinated in the room)
    • Print the count of vaccinated and not vaccinated in the room
    • Stay in the room for 5 seconds (sleep for 5 seconds)
    • Leave the SharedRoom (decrement the number of not vaccinated in the room)
  4. Write a Drive class as following:
    • Create 6 Vaccinated objects and 6 NotVaccinated objects and let them starts (you can use loop).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

Students also viewed these Databases questions

Question

Example. Evaluate 5n+7 lim 7-00 3n-5

Answered: 1 week ago