February 2014
Beginner
1248 pages
62h 25m
English
When the Producer thread’s run method invokes synchronized method blockingPut, the thread implicitly attempts to acquire the SynchronizedBuffer object’s monitor lock. If the monitor lock is available, the Producer thread implicitly acquires the lock. Then the loop at lines 14–20 first determines whether occupied is true. If so, buffer is full and we want to wait until the buffer is empty, so line 17 outputs a message indicating that the Producer thread is trying to write a value, and line 18 invokes method displayState (lines 57–61) to output another message indicating that buffer is full and that the Producer thread is waiting until there’s space. Line 19 invokes method wait (inherited from Object ...
Read now
Unlock full access