diff --git a/src/machine.cpp b/src/machine.cpp index 01b766de93..fedbf9c35f 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -45,7 +45,11 @@ void join(Thread* t, Thread* o) { if (t != o) { - o->systemThread->join(); + if (o->state != Thread::ZombieState + and o->state != Thread::JoinedState) + { + o->systemThread->join(); + } o->state = Thread::JoinedState; } } @@ -2281,6 +2285,12 @@ Thread::exit() } else { threadPeer(this, javaThread) = 0; enter(this, Thread::ZombieState); + + lock->dispose(); + lock = 0; + + systemThread->dispose(); + systemThread = 0; } } } @@ -2288,7 +2298,9 @@ Thread::exit() void Thread::dispose() { - lock->dispose(); + if (lock) { + lock->dispose(); + } if (systemThread) { systemThread->dispose(); diff --git a/src/machine.h b/src/machine.h index 4bdfccfc24..8d861717ef 100644 --- a/src/machine.h +++ b/src/machine.h @@ -2746,7 +2746,11 @@ notifyAll(Thread* t, object o) inline void interrupt(Thread*, Thread* target) { - target->systemThread->interrupt(); + if (target->state != Thread::ZombieState + and target->state != Thread::JoinedState) + { + target->systemThread->interrupt(); + } } inline void