accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cardon, Tejay E" <>
Subject RE: EXTERNAL: Double Checked Locking - broken? working?
Date Wed, 12 Sep 2012 22:01:27 GMT
If it's truly an instance of lazy instantiation, then I'd suggest using the enum holder pattern
described by Josh Bloch in Effective Java. Otherwise, volatile works, but it looks uglier.


-----Original Message-----
From: David Medinets [] 
Sent: Wednesday, September 12, 2012 3:47 PM
To: accumulo-dev
Subject: EXTERNAL: Double Checked Locking - broken? working?

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) &&
          validTableProperties = tmp;

    return validTableProperties.contains(key) ||
        || key.startsWith(Property.TABLE_ITERATOR_PREFIX.getKey()) || key.startsWith(Property.TABLE_LOCALITY_GROUP_PREFIX.getKey());

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?

View raw message