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

Reviewed-by: rpressler, dholmes, jpai
  • Loading branch information
Alan Bateman committed Jun 9, 2023
1 parent f91e9ba commit 97df6cf
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 @@ -874,13 +874,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 97df6cf

@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.