Question: Explain the behavior of the Java code for the bounded buffer problem if the keyword synchronized is removed from the put operation (line 28 of
Explain the behavior of the Java code for the bounded buffer problem if the keyword synchronized is removed from the put operation (line 28 of Figure 13.6). 
![(8) (9) (10) (11) (12) (13) (14) public static void main(String[] args)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/02/65cdfdfbb71d1_71565cdfdfb9a014.jpg)
(1) import java.io.*; (2) class BoundedBuffer { (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) public static void main(String[] args) { Buffer buffer = new Buffer (5); // buffer has size 5 Producer prod = new Producer (buffer); Consumer cons = new Consumer (buffer); Thread read = new Thread (prod); Thread write = new Thread (cons); read.start(); write.start(); try { (15) (16) } (17) } read.join(); write.interrupt (); } catch (InterruptedException e) {} (18) class Buffer { (19) private final char[] buf; Figure 13.6 Java code for a bounded buffer problem (continues)
Step by Step Solution
There are 3 Steps involved in it
In the provided Java code for the bounded buffer problem the put method in the Buffer class is decla... View full answer
Get step-by-step solutions from verified subject matter experts
