commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter royal <pro...@apache.org>
Subject Re: concurrency and starting a synchronized block
Date Thu, 10 Feb 2005 13:37:37 GMT
On Feb 10, 2005, at 8:20 AM, Jörg Schaible wrote:
> en get() twice:
>
> Object o = map.get(key);
> if (o == null) {
>   synchronized(map) {
>     o = map.get(key);
>     if (o == null) {
>       map.put(key,new Object());
>     }
>   }
> }
>
> since 99% of the time it will not enter the block, the second lookup 
> does not matter ...

Is that still enough to not be double-checked locking (which is broken 
in java..)

http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

-pete

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message