And add more informative messages.
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
public synchronized void depose(Object obj) {\r
while(isFull()) {\r
try {\r
+ System.out.println("Buffer is full: " + Thread.currentThread().getName()\r
+ + " is waiting, size: " + nbObj);\r
+\r
wait();\r
}\r
catch (InterruptedException e) {}\r
public synchronized Object preleve() {\r
while(isEmpty()) {\r
try {\r
+ System.out.println("Buffer is empty: " + Thread.currentThread().getName()\r
+ + " is waiting, size: " + nbObj);\r
wait();\r
}\r
catch (InterruptedException e) {}\r
\r
\r
public static void main (String[] args) {\r
- final int BUFFER_SIZE = 20;\r
+ final int BUFFER_SIZE = 1;\r
final int PROD_NUMBER = 10;\r
final int CONS_NUMBER = 10;\r
BufferCirc b = new BufferCirc(BUFFER_SIZE);\r