Question: public class Q { int n[]; int size; int content; synchronized int get() { while(isEmpty()) try { wait(); }catch(InterruptedException e) { System.out.println(InterruptedException caught); } Q(int
![public class Q { int n[]; int size; int content; synchronized](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3cc1be8eac_53166f3cc1b784b7.jpg)
public class Q { int n[]; int size; int content; synchronized int get() { while(isEmpty()) try { wait(); }catch(InterruptedException e) { System.out.println("InterruptedException caught"); } Q(int size) { n= new int[size]; this.size = size; content = -1; = System.out.println("Got("+content+");"+n[content]); content--; notify(); return n[content+1]; } // end of get boolean isFull() { return content==(size-1); } Il you have to write the code for put() method boolean isEmpty() { return content } -1; } // end of class
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
