June 2006
Intermediate to advanced
1344 pages
42h 52m
English
Figures 15.9–15.10 demonstrate a producer and a consumer accessing a shared cell of memory with synchronization, so that the producer always goes first, the consumer consumes only after the producer produces a value and the producer produces a new value only after the consumer consumes the previous value produced. This examples reuses interface IBuffer (Fig. 15.4) and classes Producer (Fig. 15.5) and Consumer (Fig. 15.6) from the previous example. [Note: In this example, we demonstrate synchronization with class Monitor’s Enter and Exit methods. In the next example, we demonstrate the same concepts via a lock block.]
Class SynchronizedBuffer (Figure 15.9) implements interface
Read now
Unlock full access