Question: Make this using JAVA: Introduction It is necessary for some applications to have synchronization and coordinate the behavior of threads for a cooperative task. The

Make this using JAVA:
Introduction
It is necessary for some applications to have synchronization and coordinate the behavior of threads for a cooperative task. The model is the producer and the consumer model. The producer produces the threads and the consumer reads and use the results of the threads.
Problem
Consider the service in a company. The clients take numbers and are serviced according to that number. Build a multithread application that synchronize the arrival of the customer and the service of the clerk.
Synchronize threads
An example could be the case when several threads use a shared resource. A device give number to the customers so that to manage the waiting line. Customers take a number when they arrive , and the clerk announces who is the next by looking at the device. As customers are called, the clerk increments the next customer counter by one.
The Model
The task is to build a multithreaded application that from the devices number to coordinate the behavior of the customers and a single clerk service them in the waiting line.
Design
Find the classes that are needed and the task of each one.
Use monitor mechanism for synchronization whenever it is needed. A synchronized method provides a lock mechanism on an object. It can guarantee the mutual exclusion. When an object is locked no other synchronized method can run in an object.
Provide the following improvements:
1. the initial solution considering the case of non existent customers (no serve customer that they are not in the line)
2. and the cashier will serve clients only when there are waiting clients (clerk runs only when there are customers)
3. consider the case of critical sections (sections that should not be interrupted during the execution)
For each case please provide a different set of program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!