java - FindBug says this concurrent map doesnt need synchronized -


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

Popular posts from this blog

Pull out data related to my apps from Android Play Store and iOS App Store -

Change php variable from jquery value using ajax (same page) -

How can I fetch data from a web server in an android application? -