相关疑难解决方法(0)

ConcurrentHashMap重新排序指令?

我正在研究ConcurrentHashMap的实现,让我感到困惑.

/* Specialized implementations of map methods */

        V get(Object key, int hash) {
            if (count != 0) { // read-volatile
                HashEntry<K,V> e = getFirst(hash);
                while (e != null) {
                    if (e.hash == hash && key.equals(e.key)) {
                        V v = e.value;
                        if (v != null)
                            return v;
                        return readValueUnderLock(e); // recheck
                    }
                    e = e.next;
                }
            }
            return null;
        }
Run Code Online (Sandbox Code Playgroud)

    /**
     * Reads value field of an entry under lock. Called if value
     * field ever appears to be …
Run Code Online (Sandbox Code Playgroud)

java concurrency multithreading

15
推荐指数
1
解决办法
7461
查看次数

标签 统计

concurrency ×1

java ×1

multithreading ×1