Question: Java Implement your own Java readers and writers problem for a circular buffer. Use as references the pseudocodes of assessment Concurrent Program of this module

Java
Java Implement your own Java readers and writers problem for a circular
buffer. Use as references the pseudocodes of assessment "Concurrent Program" of this
module and the case studied in section "Java Multithreading: Circular Buffer in

Implement your own Java readers and writers problem for a circular buffer. Use as references the pseudocodes of assessment "Concurrent Program" of this module and the case studied in section "Java Multithreading: Circular Buffer in Java." (see Figures 614 . 621). Upload two source files with extension. java that contain the source code of your application. One flle will have your dass MyCircularBuffer and other files will have the class My CircularBuffer Test. Note: Before submitting your application, you should edit, compile your application to guarantee the compiler produces a class fle (without complation and execution erross) which contains java bytecode which can be executed on the Java Virtual Machine (JVM) 1 Fig. 6.6: sircularBuffer.java 2 CircularBufifer synchronizes access to an array of 3// shared butfers. 5 public class CircularBuffer implements Buffer 6\{ 1/ each array element is a buffer private int buffers []={1,1,1}; 1/ occupiedBuffers maintains count of occupied buffers private int occupiedBuffers = 0 ; I variables that maintain read and write buffer Tocations private int readlocation - 0 ; private int writelocation = o; If place value into buffer public synchronized void set( int value) \{ If get name of thread that ca7led this method String name - Thread, currentThreadO. getName O; 1 1 , Fig. 6.7. ficelariuffertest.java 2 cinculariuffertest shows two threads manipulating a 3 verercular barfer. 4 Yeset up the producer and consumer threads and start them 6 public class CircularBuffertest 789fpub7icstaticvoidmain(Stringargs[])& Worceateshared object for threads: use a reference 10150. CircularBuffer rather than a Buffer reference Wiso inyoke SincularBuffer method createstateoutput Circularbuffer sharedlocation = new CircularBufferO: System.err.printin( sharedLocation, createstateoutput O ): Miset up threads Producer producer = new Producer( sharedLocation ): Consumer consumer = new Consumer ( sharedtocation ) : producer.start@; 1/ start producer chread consurer. start(); if start consumer thread 3/l end main I If end class Circularfuffortest

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 Databases Questions!