< prev index next >
src/hotspot/share/runtime/thread.cpp
Print this page
rev 52112 : [mq]: 8021335
*** 1817,1826 ****
--- 1817,1829 ----
lock.notify_all(thread);
// Ignore pending exception (ThreadDeath), since we are exiting anyway
thread->clear_pending_exception();
}
+ static bool is_daemon(oop threadObj) {
+ return (threadObj != NULL && java_lang_Thread::is_daemon(threadObj));
+ }
// For any new cleanup additions, please check to see if they need to be applied to
// cleanup_failed_attach_current_thread as well.
void JavaThread::exit(bool destroy_vm, ExitType exit_type) {
assert(this == JavaThread::current(), "thread consistency check");
*** 1908,1918 ****
while (true) {
{
MutexLockerEx ml(SR_lock(), Mutex::_no_safepoint_check_flag);
if (!is_external_suspend()) {
set_terminated(_thread_exiting);
- ThreadService::current_thread_exiting(this);
break;
}
// Implied else:
// Things get a little tricky here. We have a pending external
// suspend request, but we are holding the SR_lock so we
--- 1911,1920 ----
*** 1927,1937 ****
--- 1929,1943 ----
// and check again. Eventually we will get SR_lock without a pending
// external suspend request and will be able to mark ourselves as
// exiting.
}
// no more external suspends are allowed at this point
+ { MutexLocker mu(Threads_lock);
+ ThreadService::current_thread_exiting(this, is_daemon(threadObj()));
+ }
} else {
+ assert(!is_terminated() && !is_exiting(), "must not be exiting");
// before_exit() has already posted JVMTI THREAD_END events
}
if (log_is_enabled(Debug, os, thread, timer)) {
_timer_exit_phase1.stop();
*** 4330,4340 ****
}
void Threads::add(JavaThread* p, bool force_daemon) {
// The threads lock must be owned at this point
! assert_locked_or_safepoint(Threads_lock);
BarrierSet::barrier_set()->on_thread_attach(p);
p->set_next(_thread_list);
_thread_list = p;
--- 4336,4346 ----
}
void Threads::add(JavaThread* p, bool force_daemon) {
// The threads lock must be owned at this point
! assert(Threads_lock->owned_by_self(), "must have threads lock");
BarrierSet::barrier_set()->on_thread_attach(p);
p->set_next(_thread_list);
_thread_list = p;
*** 4346,4356 ****
_number_of_threads++;
oop threadObj = p->threadObj();
bool daemon = true;
// Bootstrapping problem: threadObj can be null for initial
// JavaThread (or for threads attached via JNI)
! if ((!force_daemon) && (threadObj == NULL || !java_lang_Thread::is_daemon(threadObj))) {
_number_of_non_daemon_threads++;
daemon = false;
}
ThreadService::add_thread(p, daemon);
--- 4352,4362 ----
_number_of_threads++;
oop threadObj = p->threadObj();
bool daemon = true;
// Bootstrapping problem: threadObj can be null for initial
// JavaThread (or for threads attached via JNI)
! if ((!force_daemon) && !is_daemon((threadObj))) {
_number_of_non_daemon_threads++;
daemon = false;
}
ThreadService::add_thread(p, daemon);
*** 4391,4401 ****
}
_number_of_threads--;
oop threadObj = p->threadObj();
bool daemon = true;
! if (threadObj == NULL || !java_lang_Thread::is_daemon(threadObj)) {
_number_of_non_daemon_threads--;
daemon = false;
// Only one thread left, do a notify on the Threads_lock so a thread waiting
// on destroy_vm will wake up.
--- 4397,4407 ----
}
_number_of_threads--;
oop threadObj = p->threadObj();
bool daemon = true;
! if (!is_daemon(threadObj)) {
_number_of_non_daemon_threads--;
daemon = false;
// Only one thread left, do a notify on the Threads_lock so a thread waiting
// on destroy_vm will wake up.
< prev index next >