[concurrency-interest] ConcurrentMap.replace

Eric Zoerner eric.zoerner@gemstone.com
Mon, 24 Nov 2003 09:32:20 -0800


I can see how this replace method is the same as putIfPresent(K key, V value, V 
expectedValue), but how would this method work for the case where I don't care 
what the current value is, but I want to replace it only if containsKey(key) is 
true? (e.g. I want to atomically replace it regardless of its current value with 
my NullObject without the side effect of adding the key it if it's been removed)?


Doug Lea wrote:


>       boolean replace(K key, V oldValue, V newValue);