Question: Develop a class called Buffer that holds a single integer value. The class has two public methods called read ( ) that returns the current
Develop a class called Buffer that holds a single integer value. The class has two public methods called read that returns the current value of the buffer and writek that writes integer k to the buffer. A thread invoking read must wait for a value to be written to the buffer. Once the item in the buffer is read it is cleared to allow a writer thread write. If the buffer contains a value a writer thread must wait for the current value of the buffer to be read by another thread.
Implement using ReentrantLock and condition variables
trystay in tunnel for random period int t intMathrandom; Thread.sleept;
catchInterruptedException e tunnel.leave;
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
