< prev index next >

src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java

Print this page

        

@@ -66,10 +66,12 @@
 import java.util.function.ToIntBiFunction;
 import java.util.function.ToIntFunction;
 import java.util.function.ToLongBiFunction;
 import java.util.function.ToLongFunction;
 import java.util.stream.Stream;
+
+import jdk.internal.misc.Strands;
 import jdk.internal.misc.Unsafe;
 
 /**
  * A hash table supporting full concurrency of retrievals and
  * high expected concurrency for updates. This class obeys the

@@ -2762,11 +2764,11 @@
      * not) to complete before tree restructuring operations.
      */
     static final class TreeBin<K,V> extends Node<K,V> {
         TreeNode<K,V> root;
         volatile TreeNode<K,V> first;
-        volatile Thread waiter;
+        volatile Object waiter;
         volatile int lockState;
         // values for lockState
         static final int WRITER = 1; // set while holding write lock
         static final int WAITER = 2; // set when waiting for write lock
         static final int READER = 4; // increment value for setting read lock

@@ -2864,11 +2866,11 @@
                     }
                 }
                 else if ((s & WAITER) == 0) {
                     if (U.compareAndSetInt(this, LOCKSTATE, s, s | WAITER)) {
                         waiting = true;
-                        waiter = Thread.currentThread();
+                        waiter = Strands.currentStrand();
                     }
                 }
                 else if (waiting)
                     LockSupport.park(this);
             }

@@ -2894,11 +2896,11 @@
                         TreeNode<K,V> r, p;
                         try {
                             p = ((r = root) == null ? null :
                                  r.findTreeNode(h, k, null));
                         } finally {
-                            Thread w;
+                            Object w;
                             if (U.getAndAddInt(this, LOCKSTATE, -READER) ==
                                 (READER|WAITER) && (w = waiter) != null)
                                 LockSupport.unpark(w);
                         }
                         return p;
< prev index next >