src/share/classes/java/lang/Thread.java
Print this page
@@ -227,11 +227,11 @@
/* The object in which this thread is blocked in an interruptible I/O
* operation, if any. The blocker's interrupt method should be invoked
* after setting this thread's interrupt status.
*/
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
*/
void blockedOn(Interruptible b) {
synchronized (blockerLock) {
@@ -686,20 +686,23 @@
*/
if (threadStatus != 0)
throw new IllegalThreadStateException();
/* 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);
- boolean failed = true;
+ boolean started = false;
try {
start0();
- failed = false;
+ started = true;
} finally {
try {
- group.threadStarted(this, failed);
+ if (!started) {
+ group.threadStartFailed(this);
+ }
} catch (Throwable ignore) {
/* do nothing. If start0 threw a Throwable then
it will be passed up the call stack */
}
}