diff --git a/src/hotspot/share/services/threadService.cpp b/src/hotspot/share/services/threadService.cpp index 494ca337cf4b2..31c4f5c91bae0 100644 --- a/src/hotspot/share/services/threadService.cpp +++ b/src/hotspot/share/services/threadService.cpp @@ -874,7 +874,10 @@ void ThreadSnapshot::initialize(ThreadsList * t_list, JavaThread* thread) { _sleep_ticks = stat->sleep_ticks(); _sleep_count = stat->sleep_count(); - _thread_status = java_lang_Thread::get_thread_status(threadObj); + // If thread is still attaching then threadObj will be NULL. + _thread_status = threadObj == NULL ? JavaThreadStatus::NEW + : java_lang_Thread::get_thread_status(threadObj); + _is_suspended = thread->is_suspended(); _is_in_native = (thread->thread_state() == _thread_in_native);