相关疑难解决方法(0)

Java 并发 Hashmap initTable() 为什么要使用 try/finally 块?

我一直在查看以下代码(来自此处)'

/**
 * Initializes table, using the size recorded in sizeCtl.
 */
private final Node<K,V>[] initTable() {
    Node<K,V>[] tab; int sc;
    while ((tab = table) == null || tab.length == 0) {
        if ((sc = sizeCtl) < 0)
            Thread.yield(); // lost initialization race; just spin
        else if (U.compareAndSetInt(this, SIZECTL, sc, -1)) {
            try {
                if ((tab = table) == null || tab.length == 0) {
                    int n = (sc > 0) ? sc : DEFAULT_CAPACITY;
                    @SuppressWarnings("unchecked")
                    Node<K,V>[] nt …
Run Code Online (Sandbox Code Playgroud)

java concurrenthashmap

2
推荐指数
1
解决办法
208
查看次数

标签 统计

concurrenthashmap ×1

java ×1