On Wed, 7 Jun 2023 22:48:47 GMT, Alex Menkov <amen...@openjdk.org> wrote:

>> Do you need to check jt->is_interrupted(false) and set INTERRUPTED bit?
>> It looks like java_lang_Thread::get_thread_status(thread_oop) can only 
>> return RUNNABLE in the case and we clear it, so the call is not needed:
>> 
>>     if (is_thread_carrying_vthread(jt, thread_oop)) {
>>       jint state = JVMTI_THREAD_STATE_WAITING | 
>> JVMTI_THREAD_STATE_WAITING_INDEFINITELY;
>>       if (jt->is_carrier_thread_suspended()) {
>>         state |= JVMTI_THREAD_STATE_SUSPENDED;
>>       }
>>       if (jt->is_interrupted(false)) {
>>         state |= JVMTI_THREAD_STATE_INTERRUPTED;
>>       }
>>       return state;
>>     } else ...
>
>> A thread carrying a virtual thread can not be in native, blocked, parked, 
>> sleeping or waiting on some object.
> 
> Actually it can be in native.
> And if I remember correctly synchronized block pins virtual thread, so inside 
> synchronized we can get other states

The INTERRUPTED bit we need has to be returned by the 
`java_lang_Thread::get_thread_status`.
Not completely sure but the bit jt->is_interrupted(false) can be set for the 
mounted virtual thread.
The JVMTI InterruptThread calls this function to set interrupt bit for 
non-virtual threads:
`  java_lang_Thread::set_interrupted(thread_obj, true);`

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14366#discussion_r1222268031

Reply via email to