diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 7e6316f025..11d4e42e34 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -53,6 +53,9 @@ DetachCurrentThread(Machine* m) ACQUIRE_RAW(t, t->m->stateLock); enter(t, Thread::ActiveState); + + threadPeer(t, t->javaThread) = 0; + enter(t, Thread::ZombieState); t->state = Thread::JoinedState; diff --git a/src/machine.cpp b/src/machine.cpp index 6e046843d0..fdbe8ed029 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2201,6 +2201,7 @@ Thread::exit() if (m->liveCount == 1) { turnOffTheLights(this); } else { + threadPeer(this, javaThread) = 0; enter(this, Thread::ZombieState); } } @@ -2209,8 +2210,6 @@ Thread::exit() void Thread::dispose() { - threadPeer(this, javaThread) = 0; - if (systemThread) { systemThread->dispose(); }