- 源码注释
java8中,每一个kv对被包装成一个Node节点,Node类是ConcurrenHashMap的内部类,核心代码如下
static class Node<K,V> implements Map.Entry<K,V> {
final int hash; // key的hash值
final K key; // key
volatile V val; // value
volatile Node<K,V> next; //指向下一个Node节点
Node(int hash, K key, V val, Node<K,V> next) {
this.hash = hash;
this.key = key;
this.val = val;
this.next = next;
}
}