O'Reilly logo

Java Thread Programming by Paul Hyde

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 17. The BooleanLock Utility

IN THIS CHAPTER

The 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.

Background

Using the wait/notify mechanism effectively and correctly requires discipline. It is easy to erroneously ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required