On Wed, Jan 2, 2013 at 10:44 AM, David Medinets <[email protected]> wrote: > I was poking around in > accumulo/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java > and noticed the following declaration: > > private final SortedMap<KeyExtent,Tablet> onlineTablets = > Collections.synchronizedSortedMap(new TreeMap<KeyExtent,Tablet>()); > > Then I also noticed this code construct in the same file: > > synchronized (openingTablets) { > openingTablets.remove(extentToOpen); > ... > openingTablets.notifyAll(); > }
notifyAll() must be called within a sync block. The javadoc for synchronizedSortedMap provides some other use cases for syncronizing on a synchronized collection. A synchronized map makes a single operation on the map atomic. If you want iterator or perform multiple operations atomically you must sync. Java locks are reentrant so its ok. > > My understanding of concurrency is slight but to my untrained eye I am > seeing a double synchronization. Am I missing something?
