If the specified key is not already associated with a value, associates it with the given value. This is equivalent to, for this {@code map}: <pre> {@code if (!map.containsKey(key)) return map.put(key, value); else return map.get(key);}</pre>
Removes the entry for a key only if currently mapped to a given value. This is equivalent to, for this {@code map}: <pre> {@code if (map.containsKey(key) && Objects.equals(map.get(key), value)) { map.remove(key); return true; } else { return false; }}</pre>
Replaces the entry for a key only if currently mapped to a given value. This is equivalent to, for this {@code map}: <pre> {@code if (map.containsKey(key) && Objects.equals(map.get(key), oldValue)) { map.put(key, newValue); return true; } else { return false; }}</pre>
Replaces the entry for a key only if currently mapped to some value. This is equivalent to, for this {@code map}: <pre> {@code if (map.containsKey(key)) return map.put(key, value); else return null;}</pre>
A {@link Map} providing thread safety and atomicity guarantees.
<p>To maintain the specified guarantees, default implementations of methods including {@link #putIfAbsent} inherited from {@link Map} must be overridden by implementations of this interface. Similarly, implementations of the collections returned by methods {@link #keySet}, {@link #values}, and {@link #entrySet} must override methods such as {@code removeIf} when necessary to preserve atomicity guarantees.
<p>Memory consistency effects: As with other concurrent collections, actions in a thread prior to placing an object into a {@code ConcurrentMap} as a key or value <a href="package-summary.html#MemoryVisibility"><i>happen-before</i></a> actions subsequent to the access or removal of that object from the {@code ConcurrentMap} in another thread.
<p>This interface is a member of the <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework"> Java Collections Framework</a>.
@author Doug Lea @param <K> the type of keys maintained by this map @param <V> the type of mapped values