[concurrency-interest] Questions on ConcurrentHashMap
jseigh_cp00 at xemaps.com
Wed Nov 28 06:23:52 EST 2007
Joe Bowbeer wrote:
> On Nov 27, 2007 10:17 PM, Grace Kwok wrote:
>> I am considering replacing my synchronized HashMap cache to be a
>> 1) Consider these operations on a populated map:
>> - map.clear() is called
>> - immediately or concurrently afterwards map.get(A) and map.get(B) are called.
>> We know for sure that if map is a synchronized HashMap, the result of
>> A and B would be null.
>> However, if map is a concurrentHashMap, the results of get(A) and
>> get(B) could be any of the followings [AResult, BResult], [null,
>> null], [AResult, null], [null, BResult]. Am I correct?
> I agree if "immediately or concurrently" means *after* map.clear() is
> called but *before* it completes.
Great! I go check the docs to see what the semantics of map.clear()
actually are in this case. It
doesn't say. So how does this work? Semantics are implementation
dependent. Is the implementation
fixed for all time or can it change?
More information about the Concurrency-interest