handle case of not-yet-started thread in setDaemon

This commit is contained in:
Joel Dice 2010-12-01 15:42:46 -07:00
parent d00f4c5390
commit 1722b68277

View File

@ -1444,12 +1444,6 @@ class Classpath {
dispose() = 0;
};
inline void
runJavaThread(Thread* t)
{
t->m->classpath->runThread(t);
}
Classpath*
makeClasspath(System* system, Allocator* allocator, const char* javaHome,
const char* embedPrefix);
@ -1759,6 +1753,16 @@ instanceOf(Thread* t, object class_, object o);
#include "type-declarations.cpp"
inline void
runJavaThread(Thread* t)
{
if (threadDaemon(t, t->javaThread)) {
atomicOr(&(t->flags), Thread::DaemonFlag);
}
t->m->classpath->runThread(t);
}
inline object&
root(Thread* t, Machine::Root root)
{
@ -2812,10 +2816,12 @@ setDaemon(Thread* t, object thread, bool daemon)
threadDaemon(t, thread) = daemon;
Thread* p = reinterpret_cast<Thread*>(threadPeer(t, thread));
if (daemon) {
atomicOr(&(p->flags), Thread::DaemonFlag);
} else {
atomicAnd(&(p->flags), ~Thread::DaemonFlag);
if (p) {
if (daemon) {
atomicOr(&(p->flags), Thread::DaemonFlag);
} else {
atomicAnd(&(p->flags), ~Thread::DaemonFlag);
}
}
if (daemon) {