Thread.interrupted() is always false in debugger

Egor Ushakov egor.ushakov at jetbrains.com
Tue Aug 20 12:32:36 UTC 2024


Hi everyone!

we have a long standing issue 
https://youtrack.jetbrains.com/issue/IDEA-169706
Maybe someone could clarify why it happens and if there's a possible 
workaround.
Here's the simplified test case:

public class Interruption {
     public static void main(String[]args) {
         Thread thread =Thread.currentThread();
         thread.interrupt();

         if (Thread.interrupted()) { // <----- stop on a breakpoint here
             System.out.println("Interrupted");
         }else {
             System.out.println("Not interrupted");
         }
     }
}

Obviously the program prints:
Interrupted But if stopped on a breakpoint in the debugger, evaluation of
Thread.interrupted() always returns false.
More of that/interrupted /field value in the thread object is also reported as false:


If interrupted method is debugged step by step it is obvious that interrupted value is true,
but the debugger continue to show it as false.

Any ideas why it could happen and how to fix it?

Thanks!
Egor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/serviceability-dev/attachments/20240820/4de5c654/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: U29ugEUZ0HjcKutG.png
Type: image/png
Size: 122053 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/serviceability-dev/attachments/20240820/4de5c654/U29ugEUZ0HjcKutG-0001.png>


More information about the serviceability-dev mailing list