Given the following code:
public class FooBar {
public static volatile ConcurrentHashMap myConfigData = new ConcurrentHashMap();
}
public class
If by update you mean overwrite an entry inside the ConcurrentHashMap:
FooBar.myConfigData.put(somekey, somevalue);
Then it is definitely thread safe, as duffymo said.
If you want to overwrite the myConfigData variable with a new value:
FooBar.myConfigData = new ConcurrentHashMap();
It is also thread-safe, as you have correctly labelled the variable as volatile. The volatile keyword means that multiple threads can access the same variable safely and atomically.
EDIT: The Question is not wether ConcurrentHashMap is threadsafe (it is according to javadoc) but rather the Setting of the ConcurrentHashMap itself in the myConfigData Member variable. This variable might be read and written "at once" by several threads so the question is, if the setting is atomic or not. I think this can be generalized, is the Setting of a Java Reference variable atomic or not.
(I also made it volatile. This is a different issue and has nothing to do with atomicity (my question) but rather "visibility in other threads" and the happens before relationship).
Actually 'volatile' is for atomicity, nothing affects visibility, a public variable will always be visible to any thread.