8309545: Thread.interrupted from virtual thread needlessly resets interrupt status

Reviewed-by: rpressler, dholmes, jpai
This commit is contained in:
Alan Bateman 2023-06-09 07:30:03 +00:00
parent f91e9ba757
commit 97df6cf55a

@ -874,13 +874,14 @@ final class VirtualThread extends BaseVirtualThread {
@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