[concurrency-interest] ConcurrentHashMap - feature request

rganesan-l@myrealbox.com rganesan-l@myrealbox.com
24 Dec 2002 09:23:17 +0530


>>>>> "Joshua" == Joshua Bloch <joshua.bloch@sun.com> writes:

> Ganesan,

> ConcurrentHashMap provides exactly the support you need.  It implements
> the ConcurrentMap implementation which consists solely of the putIfAbsent
> method.  See http://gee.cs.oswego.edu/dl/concurrent/dist/docs/index.html
> for details.  

Joshua,

I was initially confused because I was looking for exactly such a method
in ConcurrentHashMap but couldn't find one. Then Doug's mail cleared up
things :-). Actually, the ConcurrentMap interface is exactly what I
needed. Talk about having your wish satisfied before you ask for it :-).

> Also, it's worth noting that locking up the entire map in
> order to perform this operation would defeat the purpose of the class
> (high concurrency).

Yes, obviously. Looking at the ConcurrentHashMap in util.concurrent, 
locking the entire map doesn't seem to needed. Concurrency can be 
maintained at the same level as the put method. I assume that's how
the ConcurrentHashMap in JSR 166 implements it now.

Ganesan

-- 
Ganesan R