From e46e222f383d7464e5c12d424f43f8dcdb5126ed Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 13 Aug 2008 15:39:48 -0600 Subject: [PATCH] wait for other threads to exit in DestroyJavaVM --- src/jnienv.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/jnienv.cpp b/src/jnienv.cpp index ab0f18a304..96df4dd485 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -34,6 +34,14 @@ DestroyJavaVM(Machine* m) Finder* f = m->finder; Thread* t = m->rootThread; + // wait for other threads to exit + { ACQUIRE(t, m->stateLock); + + while (m->liveCount > 1) { + t->m->stateLock->wait(t->systemThread, 0); + } + } + int exitCode = (t->exception ? -1 : 0); enter(t, Thread::ActiveState); t->exit();