提交 5853a802 编写于 作者: C chegar

7013961: Threads attached via JNI attach prevent daemon ThreadGroups from being destroyed

Reviewed-by: dholmes
上级 fa156588
...@@ -690,7 +690,7 @@ class Thread implements Runnable { ...@@ -690,7 +690,7 @@ class Thread implements Runnable {
/* Notify the group that this thread is about to be started /* Notify the group that this thread is about to be started
* so that it can be added to the group's list of threads * so that it can be added to the group's list of threads
* and the group's unstarted count can be decremented. */ * and the group's unstarted count can be decremented. */
group.threadStarting(this); group.add(this);
boolean started = false; boolean started = false;
try { try {
......
...@@ -867,21 +867,6 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler { ...@@ -867,21 +867,6 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler {
} }
} }
/**
* Notifies the group that the thread {@code t} is about to be
* started and adds the thread to this thread group.
*
* The thread is now a fully fledged member of the group, even though
* it hasn't been started yet. It will prevent the group from being
* destroyed so the unstarted Threads count is decremented.
*/
void threadStarting(Thread t) {
synchronized (this) {
add(t);
nUnstartedThreads--;
}
}
/** /**
* Adds the specified thread to this thread group. * Adds the specified thread to this thread group.
* *
...@@ -910,6 +895,12 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler { ...@@ -910,6 +895,12 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler {
// This is done last so it doesn't matter in case the // This is done last so it doesn't matter in case the
// thread is killed // thread is killed
nthreads++; nthreads++;
// The thread is now a fully fledged member of the group, even
// though it may, or may not, have been started yet. It will prevent
// the group from being destroyed so the unstarted Threads count is
// decremented.
nUnstartedThreads--;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册