Communication Between Threads
[ Home ] [ Up ] [ What is MultiThreading? ] [ Threads & Thread Properties ] [ Thread Scheduling and Priority ] [ Types of Threads ] [ Monitors, Synchronization and Deadlocks ] [ Thread Coordination ] [ Communication Between Threads ] [ Threads and Thread Groups ] [ Explicit Locks ] [ Atomic Variables ] [ Blocking Queues ] [ Thread-Safe Collections ] [ Callables & Futures ] [ The Executor Framework ] [ Synchronizers ]

 

An Example

 

Using Pipes to Communicate between Threads

Sometimes the communication requirements between threads is quite simple. Take, for example, the case where the producer creates a stream of characters and the consumer reads and processes that stream.

Java has a convenient set of Piped classes that provide the support for just such a circumstance:

  • PipedReader and PipedWriter, for text data
  • PipedInputStream and PipedOutputStream, for non-text data
 
The page was last updated February 19, 2008