< prev index next >

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

Print this page

        

@@ -48,10 +48,11 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.function.Predicate;
 import java.util.concurrent.locks.LockSupport;
+import jdk.internal.misc.Strands;
 
 /**
  * An {@link ExecutorService} for running {@link ForkJoinTask}s.
  * A {@code ForkJoinPool} provides the entry point for submissions
  * from non-{@code ForkJoinTask} clients, as well as management and

@@ -1920,11 +1921,11 @@
      */
     private <T> ForkJoinTask<T> externalSubmit(ForkJoinTask<T> task) {
         Thread t; ForkJoinWorkerThread w; WorkQueue q;
         if (task == null)
             throw new NullPointerException();
-        if (((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) &&
+        if (((t = Strands.currentCarrierThread()) instanceof ForkJoinWorkerThread) &&
             (w = (ForkJoinWorkerThread)t).pool == this &&
             (q = w.workQueue) != null)
             q.push(task);
         else
             externalPush(task);

@@ -3113,11 +3114,11 @@
         throws InterruptedException {
         if (blocker == null) throw new NullPointerException();
         ForkJoinPool p;
         ForkJoinWorkerThread wt;
         WorkQueue w;
-        Thread t = Thread.currentThread();
+        Thread t = Strands.currentCarrierThread();
         if ((t instanceof ForkJoinWorkerThread) &&
             (p = (wt = (ForkJoinWorkerThread)t).pool) != null &&
             (w = wt.workQueue) != null) {
             int block;
             while (!blocker.isReleasable()) {
< prev index next >