Skip to content

Commit

Permalink
Merge pull request #51 from hangshao0/openj9
Browse files Browse the repository at this point in the history
Add synchronized block in getAndClearInterrupt()
  • Loading branch information
tajila authored Dec 1, 2022
2 parents 720d535 + b7e964a commit 1303c08
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/java.base/share/classes/java/lang/Thread.java
Original file line number Diff line number Diff line change
Expand Up @@ -1813,15 +1813,14 @@ final void clearInterrupt() {
}

boolean getAndClearInterrupt() {
boolean oldValue = interrupted;
// We may have been interrupted the moment after we read the field,
// so only clear the field if we saw that it was set and will return
// true; otherwise we could lose an interrupt.
if (oldValue) {
interrupted = false;
clearInterruptEvent();
synchronized (interruptLock) {
boolean oldValue = interrupted;
if (oldValue) {
interrupted = false;
clearInterruptEvent();
}
return oldValue;
}
return oldValue;
}

/**
Expand Down

0 comments on commit 1303c08

Please sign in to comment.