Intellij IDEA Evaluate Expression window and Thread.currentThread () value. IsInterrupted ()

For unknown reasons, I cannot get the correct value for currentThread (). isInterrupted () from Intellij IDEA Evaluate Expression window .

This is a small snippet of code that will help reproduce the same behavior:

public class IsInterruptedTest {

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

        System.out.println(Thread.currentThread().isInterrupted());
    }
}

      

To reproduce it, follow these steps:

  • Set a breakpoint on System.out.println(Thread.currentThread().isInterrupted());

  • Start main method in debug mode

  • Wait until execution reaches a breakpoint.

  • Call Thread.currentThread().isInterrupted();

    from the Calculate expression window (Alt + F8). (For me, this call returns false )

  • Resume the execution of the program and as soon as it is done check the value printed on the console. (Printed true for me )

So my question is, why are these two values ​​different?

Is this happening because the current thread is being suspended by the debugger? If so, is there a way to get the correct call value isInterrupted()

from the Express Expression window in the IDE?

+3


source to share


1 answer


This is a known and not yet fixed bug: https://youtrack.jetbrains.com/issue/IDEA-169706



+4


source







All Articles