A DESCRIPTION OF THE REQUEST :
AbstractMap has two fields which are declared volatile:
public abstract class AbstractMap<K,V> implements Map<K,V> {
.....
/**
* Each of these fields are initialized to contain an instance of the
* appropriate view the first time this view is requested. The views are
* stateless, so there's no reason to create more than one of each.
*/
transient volatile Set<K> keySet;
transient volatile Collection<V> values;
....
}
This is unnecessary since there is nothing in the API requiring these fields to be volatile.
JUSTIFICATION :
Removing volatile will reduce the cost of creating instances extending AbstractMap, as well as invoking e.g. ::values() and ::keySet() on a HashMap. In the application I'm working in hundreds of thousands HashMaps are created each second.