mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8258187: IllegalMonitorStateException in ArrayBlockingQueue
Reviewed-by: dl
This commit is contained in:
parent
11d5b04791
commit
e7c174083a
2 changed files with 30 additions and 8 deletions
|
@ -40,6 +40,7 @@ import java.util.Collection;
|
|||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/**
|
||||
|
@ -1197,13 +1198,18 @@ public abstract class AbstractQueuedLongSynchronizer
|
|||
ConditionNode node = new ConditionNode();
|
||||
long 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;
|
||||
}
|
||||
|
@ -1236,14 +1242,19 @@ public abstract class AbstractQueuedLongSynchronizer
|
|||
ConditionNode node = new ConditionNode();
|
||||
long 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;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import java.util.Collection;
|
|||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/**
|
||||
|
@ -1565,13 +1566,18 @@ public abstract class AbstractQueuedSynchronizer
|
|||
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 @@ public abstract class AbstractQueuedSynchronizer
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue