提交 0ef5fd0a 编写于 作者: C chegar

6988618: JCK test setDaemon0101 hangs on specific machine

Reviewed-by: dholmes, alanb
上级 ddd2c643
...@@ -229,7 +229,7 @@ class Thread implements Runnable { ...@@ -229,7 +229,7 @@ class Thread implements Runnable {
* after setting this thread's interrupt status. * after setting this thread's interrupt status.
*/ */
private volatile Interruptible blocker; private volatile Interruptible blocker;
private Object blockerLock = new Object(); private final Object blockerLock = new Object();
/* Set the blocker field; invoked via sun.misc.SharedSecrets from java.nio code /* Set the blocker field; invoked via sun.misc.SharedSecrets from java.nio code
*/ */
...@@ -688,16 +688,19 @@ class Thread implements Runnable { ...@@ -688,16 +688,19 @@ class Thread implements Runnable {
throw new IllegalThreadStateException(); throw new IllegalThreadStateException();
/* 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. */
group.threadStarting(this); group.threadStarting(this);
boolean failed = true; boolean started = false;
try { try {
start0(); start0();
failed = false; started = true;
} finally { } finally {
try { try {
group.threadStarted(this, failed); if (!started) {
group.threadStartFailed(this);
}
} catch (Throwable ignore) { } catch (Throwable ignore) {
/* do nothing. If start0 threw a Throwable then /* do nothing. If start0 threw a Throwable then
it will be passed up the call stack */ it will be passed up the call stack */
......
...@@ -870,9 +870,16 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler { ...@@ -870,9 +870,16 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler {
/** /**
* Notifies the group that the thread {@code t} is about to be * Notifies the group that the thread {@code t} is about to be
* started and adds the thread to this thread group. * 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) { void threadStarting(Thread t) {
synchronized (this) {
add(t); add(t);
nUnstartedThreads--;
}
} }
/** /**
...@@ -907,12 +914,10 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler { ...@@ -907,12 +914,10 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler {
} }
/** /**
* Notifies the group that the thread {@code t} has completed * Notifies the group that the thread {@code t} has failed
* an attempt to start. * an attempt to start.
* *
* <p> If the thread has been started successfully * <p> The state of this thread group is rolled back as if the
* then the group has its unstarted Threads count decremented.
* Otherwise the state of this thread group is rolled back as if the
* attempt to start the thread has never occurred. The thread is again * attempt to start the thread has never occurred. The thread is again
* considered an unstarted member of the thread group, and a subsequent * considered an unstarted member of the thread group, and a subsequent
* attempt to start the thread is permitted. * attempt to start the thread is permitted.
...@@ -923,16 +928,10 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler { ...@@ -923,16 +928,10 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler {
* @param failed * @param failed
* true if the thread could not be started successfully * true if the thread could not be started successfully
*/ */
void threadStarted(Thread t, boolean failed) { void threadStartFailed(Thread t) {
synchronized(this) { synchronized(this) {
if (failed) {
remove(t); remove(t);
} else { nUnstartedThreads++;
if (destroyed) {
return;
}
nUnstartedThreads--;
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册