Re: JavaMemoryModel: Idiom for safe, unsynchronized reads

From: Doug Lea (
Date: Tue Jun 29 1999 - 11:46:55 EDT

> (And if you use the term "immutable object", it
> would be nice to have a definition

The idea would have been easier to rigorously state if the JLS had
introduced some appropriate terminology, but I still don't see what is
wrong with the obvious definition: An immutable object is an instance
of a class in which all fields are 'final', and whose identity has
never escaped before all fields have received their final values. (A
simple, sufficient condition for this is never to leak the identity
within the constructor.)

BTW, One relevant difference between Java and some other languages is
that opportunities to prove lack of accessibility across multiple
threads are far less common. This is due to, among other things,
dynamic loading, reflection, and use of container frameworks. Thus it
is the normal, not exceptional, practice to assume that an object may
be accessed across threads. (You might not like this aspect of Java,
but it doesn't seem fair to subvert it.)

Doug Lea, Computer Science Department, SUNY Oswego, Oswego, NY 13126 USA 315-341-2688 FAX:315-341-5424  
This is the JavaMemoryModel mailing list, managed by Majordomo 1.94.4.

To send a message to the list, email To send a request to the list, email and put your request in the body of the message (use the request "help" for help). For more information, visit

This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:13 EDT