diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 7bda0458ad..0b1b34760e 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -77,8 +77,17 @@ DetachCurrentThread(Machine* m) { Thread* t = static_cast(m->localThread->get()); if (t) { + expect(t, t != m->rootThread); + m->localThread->set(0); - t->exit(); + + ACQUIRE_RAW(t, t->m->stateLock); + + enter(t, Thread::ActiveState); + enter(t, Thread::ZombieState); + + t->state = Thread::JoinedState; + return 0; } else { return -1; diff --git a/src/posix.cpp b/src/posix.cpp index 5f2fbf11c4..48096dac52 100644 --- a/src/posix.cpp +++ b/src/posix.cpp @@ -129,7 +129,7 @@ class MySystem: public System { virtual void join() { int rv UNUSED = pthread_join(thread, 0); - //expect(s, rv == 0); + expect(s, rv == 0); } virtual void dispose() {