In this chapter, we will look at more synchronization patterns. We will start with a detailed look at bounded buffers. We will look at different design approaches, such as client-throwing exceptions and polling. We will see how to make the writer sleep when the buffer is full (and how to make the reader sleep when the buffer is empty), and this makes for an elegant client contract.
We will also look at readersor writers lock, a primitive synchronization to allow either multiple concurrent readers or a single writer. The idea is to increase the system's concurrency with correctly preserved concurrency semantics. We will look at two variations—reader-friendly locks and fair locks.
We also implement a version of our own:
The chapter wraps up with a look at countdown latches, cyclic barriers...