synchronized Method Modifier

Chapter 7 - Concurrent Access to Objects and Variables

Java Thread Programming
Paul Hyde
  Copyright 1999 Sams Publishing

Summary
Having multiple threads running within an application can improve its performance and responsiveness to a user . Inevitably, these threads will have to interact with each other. Extra steps like synchronization have to be taken within the code to ensure that the threads do not corrupt any data and do not read any data that is in a temporarily inconsistent state.
In this chapter, I showed you:
  How to use volatile to force unsynchronized threads to work with the shared copy of a variable instead of a private working copy.
  How to use the synchronized method modifier on non- static methods to require a thread to get exclusive access to the object-level lock before entering the method.
  How to use the synchronized statement block to require a thread to get exclusive access to the object-level lock of the specified object before executing the code within the block.
  How to use the synchronized method modifier on static methods to require a thread to get exclusive access to the class-level lock before entering the method.
  How to work safely with the Collections API in a multithreaded environment.
  How to understand the causes of deadlocks, and how to try to avoid them.

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