February 2014
Beginner
1248 pages
62h 25m
English
The program in Figs. 23.18 and 23.19 demonstrates a Producer and a Consumer accessing a bounded buffer with synchronization. Again, we reuse interface Buffer and classes Producer and Consumer from the example in Section 23.5, except that line 28 is removed from class Producer and class Consumer. We implement the bounded buffer in class CircularBuffer (Fig. 23.18) as a circular buffer that uses a shared array of three elements. A circular buffer writes into and reads from the array elements in order, beginning at the first cell and moving toward the last. When a Producer or Consumer reaches the last element, it returns to the first and begins writing or reading, respectively, from there. ...
Read now
Unlock full access