mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8323782: Race: Thread::interrupt vs. AbstractInterruptibleChannel.begin
Co-authored-by: Alan Bateman <alanb@openjdk.org> Reviewed-by: alanb, dholmes
This commit is contained in:
parent
2705ed0a71
commit
4018b2b196
2 changed files with 98 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue