Re: JavaMemoryModel: Programmer Oriented FAQ

From: Sylvia Else (sylviae@optushome.com.au)
Date: Thu Feb 12 2004 - 01:25:53 EST


At 08:59 PM 11/02/2004 -0800, Hans Boehm wrote:

>Volatiles will typically be appreciably cheaper than synchronization,
>especially if the volatile variable is rarely written.

It is in this respect that the FAQ concerns me. While singleton guardian
pattern works for the simple form of 'static' lazy initialization, there
are other scenarios where it is not usable. I would be unhappy if the FAQ
leaves people with the false impression that the costs of synchronization
and volatile are so close together that it's not something they should
concern themselves with.

Even if people adopt the synchronization approach as a first cut, with a
view to fixing any performance problems later, they still have to
understand the issue if later they are to recognise that a potential
solution exists.

Sylvia.

-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



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