ConcurrentMap.putIfAbsent

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>

except that the action is performed atomically.

@implNote This implementation intentionally re-abstracts the inappropriate default provided in {@code Map}.

@param key key with which the specified value is to be associated @param value value to be associated with the specified key @return the previous value associated with the specified key, or {@code null} if there was no mapping for the key. (A {@code null} return can also indicate that the map previously associated {@code null} with the key, if the implementation supports null values.) @throws UnsupportedOperationException if the {@code put} operation is not supported by this map @throws ClassCastException if the class of the specified key or value prevents it from being stored in this map @throws NullPointerException if the specified key or value is null, and this map does not permit null keys or values @throws IllegalArgumentException if some property of the specified key or value prevents it from being stored in this map

interface ConcurrentMap(K, V)
V
putIfAbsent
(
K key
,)

Meta