}
+/**
+ * Set the current state of the given thread. This method should only
+ * be called while holding the threadlist-lock and after checking that
+ * the new state is valid. It is best to not call this method directly
+ * but call the specific setter methods below.
+ */
+static inline void thread_set_state(threadobject *t, int state)
+{
+ // Set the state of our internal threadobject.
+ t->state = state;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+ // Set the state of the java.lang.Thread object.
+ java_lang_Thread thread(thread_get_object(t));
+ assert(thread.is_non_null());
+ thread.set_threadStatus(state);
+#endif
+}
+
+
/* thread_set_state_runnable ***************************************************
Set the current state of the given thread to THREAD_STATE_RUNNABLE.
ThreadList::lock();
if (t->state != THREAD_STATE_TERMINATED) {
- t->state = THREAD_STATE_RUNNABLE;
+ thread_set_state(t, THREAD_STATE_RUNNABLE);
DEBUGTHREADS("is RUNNABLE", t);
}
ThreadList::lock();
if (t->state != THREAD_STATE_TERMINATED) {
- t->state = THREAD_STATE_WAITING;
+ thread_set_state(t, THREAD_STATE_WAITING);
DEBUGTHREADS("is WAITING", t);
}
ThreadList::lock();
if (t->state != THREAD_STATE_TERMINATED) {
- t->state = THREAD_STATE_TIMED_WAITING;
+ thread_set_state(t, THREAD_STATE_TIMED_WAITING);
DEBUGTHREADS("is TIMED_WAITING", t);
}
ThreadList::lock();
if (t->state != THREAD_STATE_TERMINATED) {
- t->state = THREAD_STATE_PARKED;
+ thread_set_state(t, THREAD_STATE_PARKED);
DEBUGTHREADS("is PARKED", t);
}
ThreadList::lock();
if (t->state != THREAD_STATE_TERMINATED) {
- t->state = THREAD_STATE_TIMED_PARKED;
+ thread_set_state(t, THREAD_STATE_TIMED_PARKED);
DEBUGTHREADS("is TIMED_PARKED", t);
}
ThreadList::lock();
- t->state = THREAD_STATE_TERMINATED;
+ thread_set_state(t, THREAD_STATE_TERMINATED);
DEBUGTHREADS("is TERMINATED", t);
inline java_handle_t* get_uncaughtExceptionHandler() const;
// Setters.
- inline void set_priority(int32_t value);
- inline void set_group (java_handle_t* value);
+ inline void set_priority (int32_t value);
+ inline void set_group (java_handle_t* value);
+ inline void set_threadStatus(int32_t value);
};
set(_handle, offset_group, value);
}
+inline void java_lang_Thread::set_threadStatus(int32_t value)
+{
+ set(_handle, offset_threadStatus, value);
+}
+
/**