-
Bug
-
Resolution: Fixed
-
P3
-
1.1.8, 1.4.0, 5.0, 6
-
b57
-
generic, x86
-
generic, windows_xp
The thread does not terminate immediately if it was stopped before it was started.
The API spec for method Thread.stop reads:
"It is permitted to stop a thread that has not yet been started. If the thread
is eventually started, it immediately terminates."
To reproduce the failure the following simple example can be used:
=================================================================
public class test {
public static void main(String[] argv) {
A a = new A();
a.stop();
a.start();
try {
a.join();
} catch (Throwable e) {
System.out.println("Unexpected exception" + e);
}
if(a.state) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
}
}
class A extends Thread {
public volatile boolean state = true;
public void run() {
state = false;
}
}
=================================================================
$java -version
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
$java -cp . test
Failed
======================================================================
From 6195215 (closed as a dupe of this CR):
A licensee reports the thread.stop() behavior does not follow the specifications
in thread.stop() API Document(although stop() is deprecated....)
According to the API document of thread.stop(),
.....
It is permitted to stop a thread that has not yet been started. If the thread is eventually started, it immediately terminates.
....
They hoped "when stopped thread starts , the thread terminates without doing anything."
- duplicates
-
JDK-6195215 (spec thread) Thread.stop() works differently from what API document says
- Closed
-
JDK-4223796 (thread) Bug 4082713 is not a duplicate of 4145910 and is not fixed
- Closed
- relates to
-
JDK-1235445 Thread.stop() ignored if called soon after start()
- Closed
-
JDK-4145906 Thread.stop() not implemented according to documentation
- Closed
-
JDK-6343393 (thread) Thread.stop for main method thread ignored
- Resolved
-
JDK-6335410 (spec thread) Thread.stop missing @throws NullPointerException
- Resolved
-
JDK-4314342 Mechanism for Thread.stop broken. Sparc, compilers 1 and 2.
- Closed
-
JDK-6562203 (thread) Thread doesn't terminate immediately if it was stopped before start
- Closed
-
JDK-4082713 stop signal issued before thread start is lost.
- Closed
-
JDK-4148126 Thread.stop() doesn't prevent thread being started later
- Closed