Skip to content

Commit

Permalink
Merge pull request #11 from ThanHenderson/19304
Browse files Browse the repository at this point in the history
Add synchronization when setting interrupted field in Thread::interrupt
  • Loading branch information
babsingh authored Jul 11, 2024
2 parents 8b9d0dd + 8d0fff0 commit 446f0bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/java.base/share/classes/java/lang/Thread.java
Original file line number Diff line number Diff line change
Expand Up @@ -1724,8 +1724,10 @@ public void interrupt() {
}

// Setting the interrupt status must be done before reading nioBlocker.
interrupted = true;
interrupt0(); // inform VM of interrupt
synchronized (interruptLock) {
interrupted = true;
interrupt0(); // inform VM of interrupt
}

// thread may be blocked in an I/O operation
if (this != Thread.currentThread()) {
Expand Down

0 comments on commit 446f0bd

Please sign in to comment.