CHAPTER 3

image

Waiting and Notification

Java provides a small API that supports communication between threads. Using this API, one thread waits for a condition (a prerequisite for continued execution) to exist. In the future, another thread will create the condition and then notify the waiting thread. In this chapter, I introduce you to this API.

Wait-and-Notify API Tour

The java.lang.Object class provides a Wait-and-Notify API that consists of three wait() methods, one notify() method, and one notifyAll() method. The wait() methods wait for a condition to exist; the notify() and notifyAll() methods notify waiting threads when the condition exists: ...

Get Java Threads and the Concurrency Utilities now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.