8323782: Race: Thread::interrupt vs. AbstractInterruptibleChannel.begin

Co-authored-by: Alan Bateman <alanb@openjdk.org>
Reviewed-by: alanb, dholmes
This commit is contained in:
Richard Reingruber 2024-02-16 08:40:13 +00:00
parent 2705ed0a71
commit 4018b2b196
2 changed files with 98 additions and 6 deletions

View file

@ -1702,24 +1702,25 @@ public class Thread implements Runnable {
public void interrupt() {
if (this != Thread.currentThread()) {
checkAccess();
}
// thread may be blocked in an I/O operation
// Setting the interrupt status must be done before reading nioBlocker.
interrupted = true;
interrupt0(); // inform VM of interrupt
// thread may be blocked in an I/O operation
if (this != Thread.currentThread()) {
Interruptible blocker;
synchronized (interruptLock) {
blocker = nioBlocker;
if (blocker != null) {
interrupted = true;
interrupt0(); // inform VM of interrupt
blocker.interrupt(this);
}
}
if (blocker != null) {
blocker.postInterrupt();
return;
}
}
interrupted = true;
interrupt0(); // inform VM of interrupt
}
/**