Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Accumulo >> mail # dev >> Double Checked Locking - broken? working?


Copy link to this message
-
Re: Double Checked Locking - broken? working?
It's a private static field that never changes once we do the initial load.
The load looks idempotent, so I'm not sure it's worth the hassle of trying
to synchronize on it, or even do it lazily. Maybe somebody with more
history has seen that it is way more performance intensive than I give it
credit for, but I think we should just throw that part in a static block
and be done with it.

Alternatively, in the middle of that article, he suggests that if you have
a static singleton (which this appears to be) that you can throw it in
another class and the memory model will work out.

-Mike

On Thu, Sep 13, 2012 at 12:25 AM, Eric Newton <[EMAIL PROTECTED]> wrote:

> The article is correct. Just go ahead and simplify the code.
>
> -Eric
>
> On Wed, Sep 12, 2012 at 5:47 PM, David Medinets <[EMAIL PROTECTED]
> >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?
> >
>
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB