accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Newton <eric.new...@gmail.com>
Subject Re: Double Checked Locking - broken? working?
Date Wed, 12 Sep 2012 23:25:15 GMT
The article is correct. Just go ahead and simplify the code.

-Eric

On Wed, Sep 12, 2012 at 5:47 PM, David Medinets <david.medinets@gmail.com>wrote:

> I see the following code in the Property class:
>
>   public static boolean isValidTablePropertyKey(String key) {
>     if (validTableProperties == null) {
>       synchronized (Property.class) {
>         if (validTableProperties == null) {
>           HashSet<String> tmp = new HashSet<String>();
>           for (Property p : Property.values())
>             if (!p.getType().equals(PropertyType.PREFIX) &&
> p.getKey().startsWith(Property.TABLE_PREFIX.getKey()))
>               tmp.add(p.getKey());
>           validTableProperties = tmp;
>         }
>       }
>     }
>
>     return validTableProperties.contains(key) ||
> key.startsWith(Property.TABLE_CONSTRAINT_PREFIX.getKey())
>         || key.startsWith(Property.TABLE_ITERATOR_PREFIX.getKey()) ||
> key.startsWith(Property.TABLE_LOCALITY_GROUP_PREFIX.getKey());
>   }
>
> However,
> http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
> says that Double Check Locking does not work. Is there any reason to
> believe that the article is incorrect? At the end of the article, it
> recommends using volatile in Java 1.5 and above. Is there any reason
> the code should not be changed to use the volatile technique?
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message