/** * Returns the <code>thread</code>'s state according * to JVMTI specification. See <a href=http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html#GetThreadState> * JVMTI Specification </a> for more details. * * @param[in] java_thread thread those state is to be queried * @param[out] state resulting thread state * */ IDATA VMCALL jthread_get_jvmti_state(jthread java_thread, jint * state) { assert(state); assert(java_thread); hythread_t native_thread = jthread_get_native_thread(java_thread); vm_thread_t vm_thread = jthread_get_vm_thread(native_thread); *state = 0; if (!native_thread) { // Not started yet return TM_ERROR_NONE; } if (hythread_is_alive(native_thread)) { *state |= JVMTI_THREAD_STATE_ALIVE; } if (hythread_is_runnable(native_thread)) { *state |= JVMTI_THREAD_STATE_RUNNABLE; } if (hythread_is_blocked_on_monitor_enter(native_thread)) { *state |= JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER; } if (hythread_is_waiting(native_thread)) { *state |= JVMTI_THREAD_STATE_WAITING; } if (hythread_is_waiting_indefinitely(native_thread)) { *state |= JVMTI_THREAD_STATE_WAITING_INDEFINITELY; } if (hythread_is_waiting_with_timeout(native_thread)) { *state |= JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT; } if (hythread_is_sleeping(native_thread)) { *state |= JVMTI_THREAD_STATE_SLEEPING; } if (hythread_is_in_monitor_wait(native_thread)) { *state |= JVMTI_THREAD_STATE_IN_OBJECT_WAIT; } if (hythread_is_parked(native_thread)) { *state |= JVMTI_THREAD_STATE_PARKED; } if (hythread_interrupted(native_thread)) { *state |= JVMTI_THREAD_STATE_INTERRUPTED; } if (hythread_is_in_native(native_thread)) { *state |= JVMTI_THREAD_STATE_IN_NATIVE; } if (hythread_is_terminated(native_thread)) { *state |= JVMTI_THREAD_STATE_TERMINATED; } if (vm_thread && vm_thread->suspend_flag) { *state |= JVMTI_THREAD_STATE_SUSPENDED; } return TM_ERROR_NONE; } // jthread_get_jvmti_state
/** * Returns <code>true</code> if the thread <code>thread</code> is interrupted. * * Otherwise returns <code>false</code>. * * @param[in] java_thread thread to be checked * @return <code>true</code> if the thread <code>thread</code> * is interrupted; <code>false</code> otherwise. * @sa java.lang.Thread.isInterrupted() */ jboolean jthread_is_interrupted(jthread java_thread) { hythread_t tm_native_thread = jthread_get_native_thread(java_thread); return hythread_interrupted(tm_native_thread) > 0; } // jthread_is_interrupted