-
Bug
-
Resolution: Fixed
-
P2
-
1.1.6, 1.2.0, 1.3.0, 1.3.1, 1.4.1
-
tiger
-
x86, sparc
-
generic, linux, solaris_2.4, solaris_8, windows_nt, windows_2000
-
Verified
JDK 1.4 does not throw the IllegalThreadStateException if the thread's function
start() is called twice. Strangely enough, it seems as if the 1.4 JVM optimized
the loop so that the dummy1's start() is only called once.
I can make the program to throw IllegalThreadStateException by:
- Run it with jdk 1.2 or lower.
- Comment out the dummy2 instantiation and start i.e.
// (new dummy2()).start();
Please see the following attachment of program's output and code sample.
--------------------------------------------------------------------------------
%jdk1.4 test
Gonna call start()!
dummy1 done!
Done calling start()!
Gonna call start()!
dummy2 done!
Done calling start()!
dummy2 done!
% jdk1.2 test
Gonna call start()!
Done calling start()!
Gonna call start()!
Exception in thread "main" java.lang.IllegalThreadStateException
at java.lang.Thread.start(Native Method)
at test.<init>(Compiled Code)
at test.main(Compiled Code)
dummy1 done!
dummy2 done!
--------------------------------------------------------------------------------
public class test {
private dummy1 t1 = new dummy1();
public static void main(String args[]) {
new test();
}
test() {
for (int j = 0; j < 2; j++) {
System.out.println("Gonna call start()!");
t1.start();
(new dummy2()).start();
System.out.println("Done calling start()!");
}
}
public class dummy1 extends Thread {
public void run() {
System.out.println("dummy1 done!");
}
}
public class dummy2 extends Thread {
public void run() {
System.out.println("dummy2 done!");
}
}
}
start() is called twice. Strangely enough, it seems as if the 1.4 JVM optimized
the loop so that the dummy1's start() is only called once.
I can make the program to throw IllegalThreadStateException by:
- Run it with jdk 1.2 or lower.
- Comment out the dummy2 instantiation and start i.e.
// (new dummy2()).start();
Please see the following attachment of program's output and code sample.
--------------------------------------------------------------------------------
%jdk1.4 test
Gonna call start()!
dummy1 done!
Done calling start()!
Gonna call start()!
dummy2 done!
Done calling start()!
dummy2 done!
% jdk1.2 test
Gonna call start()!
Done calling start()!
Gonna call start()!
Exception in thread "main" java.lang.IllegalThreadStateException
at java.lang.Thread.start(Native Method)
at test.<init>(Compiled Code)
at test.main(Compiled Code)
dummy1 done!
dummy2 done!
--------------------------------------------------------------------------------
public class test {
private dummy1 t1 = new dummy1();
public static void main(String args[]) {
new test();
}
test() {
for (int j = 0; j < 2; j++) {
System.out.println("Gonna call start()!");
t1.start();
(new dummy2()).start();
System.out.println("Done calling start()!");
}
}
public class dummy1 extends Thread {
public void run() {
System.out.println("dummy1 done!");
}
}
public class dummy2 extends Thread {
public void run() {
System.out.println("dummy2 done!");
}
}
}
- duplicates
-
JDK-4180576 Thread.start() doesn't throw IllegalThreadStateException
-
- Closed
-
-
JDK-4422466 IllegalThreadStateException: Dead Thread not thrown in 1.3.0
-
- Closed
-