mirror of
https://github.com/corda/corda.git
synced 2025-01-21 03:55:00 +00:00
wait until all non-daemon threads exit before invoking the class library shutdown method
Running the shutdown method prematurely can cause deadlock in OpenJDK's AWT implementation and may have other nasty effects besides that.
This commit is contained in:
parent
fcfdd6be3a
commit
6507150246
@ -74,12 +74,20 @@ DetachCurrentThread(Machine* m)
|
||||
uint64_t
|
||||
destroyJavaVM(Thread* t, uintptr_t*)
|
||||
{
|
||||
// wait for other non-daemon threads to exit
|
||||
{ ACQUIRE(t, t->m->stateLock);
|
||||
while (t->m->liveCount - t->m->daemonCount > 1) {
|
||||
t->m->stateLock->wait(t->systemThread, 0);
|
||||
}
|
||||
}
|
||||
|
||||
{ ENTER(t, Thread::ActiveState);
|
||||
|
||||
t->m->classpath->shutDown(t);
|
||||
}
|
||||
|
||||
// wait for other non-daemon threads to exit
|
||||
// wait again in case the Classpath::shutDown process started new
|
||||
// threads:
|
||||
{ ACQUIRE(t, t->m->stateLock);
|
||||
while (t->m->liveCount - t->m->daemonCount > 1) {
|
||||
t->m->stateLock->wait(t->systemThread, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user