java - FindBug says this concurrent map doesnt need synchronized -
this question has answer here:
so i've discovered findbug, it's making me think don't know i'm doing in couple of places. 1 of them
private map<string, object> map = new concurrenthashmap<string, object>(); public void method1(){ synchronized(map){ // findbug says unnecessary (string keys: map.keyset()){ ... } } }
i thought needed synchronize iteration, or case of findbug not being smart enough realize it's necessary? want make sure!
the iterators concurrenthashmap
"weakly consistent," meaning reflect state of map @ time iterator created may not reflect modifications made map after iterator created; in other words, iterator isn't going throw concurrentmodificationexception,
don't need lock underlying map.
Comments
Post a Comment