February 2014
Beginner
1248 pages
62h 25m
English
The synchronization is handled in class SynchronizedBuffer’s blockingPut and blockingGet methods (Fig. 23.16), which implements interface Buffer (line 4). Thus, the Producer’s and Consumer’s run methods simply call the shared object’s synchronized blockingPut and blockingGet methods. Again, we output messages from this class’s synchronized methods for demonstration purposes only—I/O should not be performed in synchronized blocks, because it’s important to minimize the amount of time that an object is “locked.”
Read now
Unlock full access