I have following piece of code :
public Hashmap<String,String> tempmap = new HashMap<String,String>();
and a class function :
void f1(){
synchronized(onClassVariable1){
....Some code onClassVariable1...
String tempString = tempMap.toString();
... Some work onClassVarible1 and tempString ...
}
}
Multiple thread call this function f1 through an object of this class ..
is this function thread-safe ??
It depends on whether there are methods which don’t synchronize on
onClassVariable1and modifytempMap.