Java Gurus,
Currently we have a HashMap which is being read frequently and modified occasionally and w
It seems you are not sure as to how what Peter Lawrey suggests can be implemented. It could look like this:
class YourClass {
private volatile Map map;
//constructors etc.
public void reload() {
Map newMap = getNewValues();
map = Collections.unmodifiableMap(newMap);
}
}
There are no concurrency issues because:
getNewValues does not need to be synchronized or atomicmap is atomicmap is volatile, which guarantees that other threads will see the change