5 things you didn't know about multithreaded Java programming
1. Synchronized method or synchronized block?
Listing 1. Two approaches to synchronization
2. ThreadLocal variables
3. Volatile variables
4. Volatile versus synchronized
5. Atomic field updaters
Using atomic updates
Listing 2. Book class
Listing 3. MyObject class
A reflection-based utility that enables atomic updates to designated volatile reference fields of designated classes. This class is designed for use in atomic data structures in which several reference fields of the same node are independently subject to atomic updates.
Listing 4. Test case that exercises the atomic update
By : Steven Haines, Founder and CEO, GeekCap Inc.
Source: IBM developerworks