[concurrency-interest] a special detaila about ConcurrentHashMapV8

ma zhen mz1999 at gmail.com
Tue Jul 31 01:43:42 EDT 2012

I notice a very small change from ConcurrentHashMap to ConcurrentHashMapV8

static final class HashEntry<K,V> {
        final K key;
        final int hash;
        volatile V value;
        final HashEntry<K,V> next;

static class Node {
        volatile int hash;
        final Object key;
        volatile Object val;
        volatile Node next;

In ConcurrentHashMap, Entry's 'next' field is final, which means the
relationship among entries is read-only after it have been created.
In contrast, 'next' field defined in ConcurrentHashMapV8 is volatile, so
the structure of nodes can be modified.
I think read-only structure can provide more concurrency because it need
not add lock when go through the enties, although this way involves many
object copy.

I wonder what's the purpose to make this change, and what's advantage to do

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120731/e239de00/attachment.html>

More information about the Concurrency-interest mailing list