<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
Hi everyone!<br>
<br>
we have a long standing issue
<a class="moz-txt-link-freetext" href="https://youtrack.jetbrains.com/issue/IDEA-169706">https://youtrack.jetbrains.com/issue/IDEA-169706</a><br>
Maybe someone could clarify why it happens and if there's a possible
workaround.<br>
Here's the simplified test case:<br>
<div style="background-color:#ffffff;color:#080808">
<pre
style="font-family:'Source Code Pro',monospace;font-size:12,0pt;"><span
style="color:#0033b3;">public class </span><span
style="color:#000000;">Interruption </span>{
<span style="color:#0033b3;">public static void </span><span
style="color:#00627a;">main</span>(<span style="color:#000000;">String</span>[] <span
style="color:#000000;">args</span>) {
<span style="color:#000000;">Thread thread </span>= <span
style="color:#000000;">Thread</span>.<span
style="font-style:italic;">currentThread</span>();
<span style="color:#000000;">thread</span>.interrupt();
<span style="color:#0033b3;">if </span>(<span
style="color:#000000;">Thread</span>.<span
style="font-style:italic;">interrupted</span>()) { // <----- stop on a breakpoint here
<span style="color:#000000;">System</span>.<span
style="color:#871094;font-style:italic;">out</span>.println(<span
style="color:#067d17;">"Interrupted"</span>);
} <span style="color:#0033b3;">else </span>{
<span style="color:#000000;">System</span>.<span
style="color:#871094;font-style:italic;">out</span>.println(<span
style="color:#067d17;">"Not interrupted"</span>);
}
}
}
Obviously the program prints:
<span style="color:#067d17;">Interrupted
</span><font color="#000000">But if stopped on a breakpoint in the debugger, evaluation of </font>
<span style="color:#000000;">Thread</span>.<span
style="font-style:italic;">interrupted</span>() always returns false.
More of that <i>interrupted </i>field value in the thread object is also reported as false:
<img src="cid:part1.0kKqwZN7.J5KQ0NPA@jetbrains.com" alt="">
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
</pre>
</div>
</body>
</html>