[concurrency-interest] ConcurrentHashMap - feature request

rganesan-l@myrealbox.com rganesan-l@myrealbox.com
24 Dec 2002 09:28:59 +0530


>>>>> "Doug" == Doug Lea <dl@cs.oswego.edu> writes:

> What Josh said is true about JSR-166, but not true of the
> ConcurrentHashMap in dl.util.concurrent. 

Thanks. I was confused for a moment :-). 

> If you need something now, I can send you the preliminary implementation
> of the JSR-166 version.

That would be a help, thanks. Reading the current ConcurrentHashMap
implementation, it appears that I only need modify the following inner loop 
in the put method 

-----
      for (Entry e = first; e != null; e = e.next) {
        if (e.hash == hash && eq(key, e.key)) {
          Object oldValue = e.value; 
          e.value = value;
          return oldValue;
        }
      }
-----

to

-----
      for (Entry e = first; e != null; e = e.next) {
        if (e.hash == hash && eq(key, e.key)) {
          Object oldValue = e.value; 
          if (oldValue == null)
            e.value = value;
          return oldValue;
        }
      }
-----

for putIfAbsent(). I did read your announcement that the next release of
dl.util.concurrent will be a draft implementation of JSR-166. Do you have
a time frame? Thanks again.

-- 
Ganesan R