I have a CHM
private ConcurrentHashMap<Integer,Integer>pR = new ConcurrentHashMap<>();
I have a Method that increments its value
public void incrementPR(int count){
Integer value = this.pR.get(count);
if(value == null){
this.pR.put(count,1);
} else {
this.pR.put(count,value+1);
}
}
This method is called from an endpoint using jmeter if i fire 500 concurrent request the value that the hashmap holes its not 500 but 437 , 430 etc its not behaving in thread safe manner , how do we acheive thready saftey for the same