Question: 1 . ( 2 5 points ) Exercise 6 . 2 0 ( fixing HardwareData ) The HardwareData class in this programLinks to an external
points Exercise fixing HardwareData
The HardwareData class in this programLinks to an external site. abstracts the idea of the getandset and swap instructions. However, this class is not considered thread safe, because multiple threads may concurrently access its methods and thread safety required that each method be performed atomically. Rewrite the class HardwareData methods using Java synchronization so that they are thread safe.
Exercise interface Channel
Implement the Channel interface see page in the book's Edition andor Sample Projects in Module so that the send and receive methods of the Message Queue are blocking. That is a thread invoking send will block if the channel is full. If the channel is empty, a thread invoking receive method will similarly block. To do this will require storing the messages in a fixedlength array. Ensure that your implementation is thread safe using Java synchronization and that the messages are stored in the FIFO order.
Exercise The Sleeping Barber Problem
A barber shop consists of a waiting room with chairs and a barber room with one barber chair. If there are no customers to be served, the barber goes to sleep. If a customer enters the barbershop and all chairs are occupied, then the customer leaves the shop. If the barber is busy but chairs are available, then the customer sits in one of the free chairs. If the barber is asleep, the customer wakes up the barber, Write a program to coordinate the barber and the customers using Java synchronization.
Exercise the singlelane bridge problem
A singlelane bridge connects two villages of North Tunbridge and South Tunbridge. Farmers in the two villages use this bridge to deliver their produce to the neighboring town. The bridge can become deadlocked if both a northbound and a southbound farmer get on the bridge at the same time assume that farmers are stubborn and are unable to back up Use Java synchronization to design an algorithm that prevents deadlock. Initially, do not be concerned about starvation the situation in which northbound farmers prevent southbound farmers from using the bridge, or vice versa
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
