Question: Please give the answer in text format. 1 hour time The producer-consumer code for storing in a single integer was explained in class. Now, that

Please give the answer in text format. 1 hour time

Please give the answer in text format. 1 hour time The producer-consumer

The producer-consumer code for storing in a single integer was explained in class. Now, that code would be extended to be used for an array of integers where the producer or consumer will add or consume from one end of the array only; that means items will be added at last of the array and consumed from last of the array as well. The code below shows the extended version of class Q (from class lecture) and also the 'put() method has been changed accordingly. Now, you have to write code for the lint gett() method only so that it works correctly. ONLY write the 'get' method in answer. public class Q { int n[]; int size; int content; Q(int size) { n-new int[size]; this.size = size; content=-1; synchronized void put(int val) { while(isFull) try { wait(); }catch(InterruptedException e) { System.out.println("InterruptedException caught"); } content++; n[content] val; System.out.println("Put("+ content +");"1 val); notify; } // end of put // you have to write code for get() method boolean isFullo { return content-size-1); boolean isEmpty() { return content -1; } // end of class

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!