src/share/classes/java/lang/ThreadGroup.java
Print this page
*** 868,881 ****
--- 868,888 ----
}
/**
* 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.
*
* <p> Note: This method is called from both library code
*** 905,920 ****
nthreads++;
}
}
/**
! * Notifies the group that the thread {@code t} has completed
* an attempt to start.
*
! * <p> If the thread has been started successfully
! * 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
* considered an unstarted member of the thread group, and a subsequent
* attempt to start the thread is permitted.
*
* @param t
--- 912,925 ----
nthreads++;
}
}
/**
! * Notifies the group that the thread {@code t} has failed
* an attempt to start.
*
! * <p> The state of this thread group is rolled back as if the
* attempt to start the thread has never occurred. The thread is again
* considered an unstarted member of the thread group, and a subsequent
* attempt to start the thread is permitted.
*
* @param t
*** 921,942 ****
* the Thread whose start method was invoked
*
* @param failed
* true if the thread could not be started successfully
*/
! void threadStarted(Thread t, boolean failed) {
synchronized(this) {
- if (failed) {
remove(t);
! } else {
! if (destroyed) {
! return;
}
- nUnstartedThreads--;
}
- }
- }
/**
* Notifies the group that the thread {@code t} has terminated.
*
* <p> Destroy the group if all of the following conditions are
--- 926,941 ----
* the Thread whose start method was invoked
*
* @param failed
* true if the thread could not be started successfully
*/
! void threadStartFailed(Thread t) {
synchronized(this) {
remove(t);
! nUnstartedThreads++;
}
}
/**
* Notifies the group that the thread {@code t} has terminated.
*
* <p> Destroy the group if all of the following conditions are