[concurrency-interest] a question regarding thedouble-checke dlocking

Bill Pugh pugh at cs.umd.edu
Mon Jun 19 11:49:42 EDT 2006


Oops. Doug observed that it is actually on the JMM FAQ web page.

I believe that will be updated shortly.

	Bill

On Jun 19, 2006, at 10:26 AM, Bill Pugh wrote:

>
> On Jun 19, 2006, at 5:29 AM, Yechiel Feffer wrote:
>
>> I am concerned with general correctness of my code,
>> want to avoid the price of volatile, here is a quote from jsr133 FAQ
>> "However, for fans of double-checked locking (and we really hope  
>> there are none left), the news is still not good. The whole point  
>> of double-checked locking was to avoid the performance overhead of  
>> synchronization. Not only has brief synchronization gotten a LOT  
>> less expensive since the Java 1.0 days, but under the new memory  
>> model, the performance cost of using volatile goes up, almost to  
>> the level of the cost of synchronization. So there's still no good  
>> reason to use double-checked-locking"
>>
>
>
> That is not from the JSR 133 FAQ.
>
> The person who wrote that doesn't know what they are talking about.
>
> The cost of a volatile read is significantly less than  
> synchronization.
> In fact, you would be hard pressed to find an increase over the  
> cost of
> a normal read in a double checked locking usage.
>
> 	Bill



More information about the Concurrency-interest mailing list