Concurrent Programming in Java
© 1996-1999 Doug Lea  



2.2 Synchronization


Section 2.2.4 (Statics and Singletons)

As of the second edition of the Java Language Specification, the remark about relying on static initializers can be strengthened: The specification now promises that statics will NOT be initialized until immediately before a class is used. (Although the sense of "used" can require caution. For example, for class C, a reference to C.class appears to count as a use.) See the JMM page on double-check for some guidance on exploiting this guarantee in solving lazy initialization problems.

Readings and Resources

For information about ongoing work on the memory model, see Bill Pugh's Java Memory Model site. This includes web pages, downloadable slides and papers, mailing list archives, and links presenting more details on the interactions between synchronization and memory access, and the current status of the revised memory model specification.

Features of computer architectures that impact multithreaded programs are described in:

Memory consistency models are the subject of increasing attention as both multiprocessors and multithreaded programs become more common and their interactions become more of a concern. At least with respect to locking, the Java memory model is closest to the family of release consistency models. For an overview, see:

Doug Lea
Last modified: Sat Oct 21 19:23:29 EDT 2000