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

Rémi Forax forax at univ-mlv.fr
Mon Jun 19 11:09:32 EDT 2006


Bill Pugh a écrit :
> 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.
>   
using google the quote seems issued from this thread :
http://www.theserverside.com/patterns/thread.tss?thread_id=39606#206141
not from the 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
Rémi Forax



More information about the Concurrency-interest mailing list