How would double-checked -- a problematic pattern at the best of times in java (see http://en.wikipedia.org/wiki/Double-checked_locking) -- help here? What you thinking? We can't really do putIfAbsent w/ a connection instance?
Good on you Akash, St.Ack On Tue, Aug 23, 2011 at 11:45 AM, Akash Ashok <[email protected]> wrote: > Hi, > I have pasted the code below for HConnectionManager.getConnection > > public static HConnection getConnection(Configuration conf) > throws ZooKeeperConnectionException { > HConnectionKey connectionKey = new HConnectionKey(conf); > synchronized (HBASE_INSTANCES) { > HConnectionImplementation connection = > HBASE_INSTANCES.get(connectionKey); > if (connection == null) { > connection = new HConnectionImplementation(conf); > HBASE_INSTANCES.put(connectionKey, connection); > } > connection.incCount(); > return connection; > } > } > > just curious as to why double checked locking isn't implemented here ? Is it > because there's won't be too many threads calling this method simultaneouly. > ? > > Cheers, > Akash A >
