--- old/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java 2021-01-09 11:35:54.456949288 -0800 +++ new/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java 2021-01-09 11:35:54.132951838 -0800 @@ -40,6 +40,7 @@ import java.util.Date; import java.util.concurrent.TimeUnit; import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.RejectedExecutionException; import jdk.internal.misc.Unsafe; /** @@ -137,13 +138,13 @@ * of exclusive synchronization takes the form: * *
- * Acquire:
+ * Acquire:
  *     while (!tryAcquire(arg)) {
  *        enqueue thread if it is not already queued;
  *        possibly block current thread;
  *     }
  *
- * Release:
+ * Release:
  *     if (tryRelease(arg))
  *        unblock the first queued thread;
  * 
@@ -1565,13 +1566,18 @@ ConditionNode node = new ConditionNode(); int savedState = enableWait(node); LockSupport.setCurrentBlocker(this); // for back-compatibility - boolean interrupted = false; + boolean interrupted = false, rejected = false; while (!canReacquire(node)) { if (Thread.interrupted()) interrupted = true; else if ((node.status & COND) != 0) { try { - ForkJoinPool.managedBlock(node); + if (rejected) + node.block(); + else + ForkJoinPool.managedBlock(node); + } catch (RejectedExecutionException ex) { + rejected = true; } catch (InterruptedException ie) { interrupted = true; } @@ -1604,14 +1610,19 @@ ConditionNode node = new ConditionNode(); int savedState = enableWait(node); LockSupport.setCurrentBlocker(this); // for back-compatibility - boolean interrupted = false, cancelled = false; + boolean interrupted = false, cancelled = false, rejected = false; while (!canReacquire(node)) { if (interrupted |= Thread.interrupted()) { if (cancelled = (node.getAndUnsetStatus(COND) & COND) != 0) break; // else interrupted after signal } else if ((node.status & COND) != 0) { try { - ForkJoinPool.managedBlock(node); + if (rejected) + node.block(); + else + ForkJoinPool.managedBlock(node); + } catch (RejectedExecutionException ex) { + rejected = true; } catch (InterruptedException ie) { interrupted = true; }