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

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -