IN THIS CHAPTER
BooleanLock class, which I present in this chapter, provides a useful encapsulation of a
boolean variable that is easily and safely accessed from multiple threads. These threads can test and set the internal value and wait for it to change. The wait/notify mechanism is used internally to support waiting for the value to change, and frees external classes from the error-prone complexity of properly implementing this mechanism.
Using the wait/notify mechanism effectively and correctly requires discipline. It is easy to erroneously ...