Skip to content

Commit

Permalink
8309545: Thread.interrupted from virtual thread needlessly resets int…
Browse files Browse the repository at this point in the history
…errupt status

Backport-of: 97df6cf55ab66552612bf0a2eefb83c0783fd586
  • Loading branch information
Rob McKenna committed Sep 15, 2023
1 parent 5524b5e commit 918ce3e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/java.base/share/classes/java/lang/VirtualThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -864,13 +864,14 @@ public boolean isInterrupted() {
@Override
boolean getAndClearInterrupt() {
assert Thread.currentThread() == this;
synchronized (interruptLock) {
boolean oldValue = interrupted;
if (oldValue)
boolean oldValue = interrupted;
if (oldValue) {
synchronized (interruptLock) {
interrupted = false;
carrierThread.clearInterrupt();
return oldValue;
carrierThread.clearInterrupt();
}
}
return oldValue;
}

@Override
Expand Down

1 comment on commit 918ce3e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.