synchronized Statement Block

Chapter 8 - Inter-thread Communication

Java Thread Programming
Paul Hyde
  Copyright 1999 Sams Publishing

Chapter 8: Inter-thread Communication
Overview
When multiple threads are running inside an application, most of them will need to communicate with each other in some form. In Chapter 5, Gracefully Stopping Threads, crude inter-thread communication was accomplished by one thread interrupting another thread. As a general guideline, the use of interrupt() should be reserved for situations where you want to interrupt a thread to signal it to die gracefully.
In the last chapter, you saw how the use of synchronized (or in some cases the use of volatile ) is needed to be sure that one thread can safely write values that another thread can safely read. In this chapter, Ill show you how one thread can signal another thread that it has made a change.
In this chapter, Ill show you how to use the following:
  The wait(), notify(), and notifyAll() methods of Object
  The join() method of Thread
  The classes PipedInputStream, PipedOutputStream, PipedReader, and PipedWriter
  The classes ThreadLocal and InheritableThreadLocal

Toc


Java Thread Programming
Java Thread Programming
ISBN: 0672315858
EAN: 2147483647
Year: 2005
Pages: 149
Authors: Paul Hyde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net