Thread.interrupted() is always false in debugger
Alan Bateman
alan.bateman at oracle.com
Wed Aug 21 10:11:40 UTC 2024
On 21/08/2024 10:50, Egor Ushakov wrote:
> Hi Chris,
>
> I tried it on jdk 23 and it works the same way :(
> It is clear that calling Thread.interrupted() in debugger should
> modify the interrupted state, but it does not...
> It looks like the debugger is taking thread interrupted state from
> somewhere else, and also somehow calling different methods...
> Check the attached video for more details.
As Chris said, the JDWP agent uses JVMTI RawMonitorWait so it has to
handle JVMTI_ERROR_INTERRUPT (which must clear the interrupt status) and
then reassert the interrupt status later. It would be useful to check
the value of ThreadNode.pendingInterrupt to see that it is true, that
would at least show that the interrupt status will be restored.
-Alan
More information about the serviceability-dev
mailing list