7.4. Interthread Communication

While threads can, of course, act in isolation (in fact, a design that requires no communication between threads lends itself to a far simpler implementation), sometimes it is necessary for threads to communicate with each other. Often, the type of communication will be fairly simple, such as reading or modifying a public member variable, or invoking an object method. Other times, more sophisticated communication is called for. Two good options for communication are communication pipes and the wait()/notify() methods, which allow one thread to notify a waiting thread of an event.

7.4.1. Communication Pipes between Threads

Like multiprocess communication, which uses pipes to send data from one process to another, ...

Get Java™ Network Programming and Distributed Computing 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.