Name: mf23781 Date: 06/12/98
The Java Language Specification and the JDK documentation clearly
states that if a thread that has been stopped with Thread.stop()
is subsequently started with Thread.start(), the thread terminates
immediately.
However, in the current implementation of the JDK, the thread executes
to completion normally instead of being "terminated immediately".
//
// In the documentation of Thread.stop(), it states:
//
// "It is permitted to stop a thread that has not yet been started.
// If the thread is eventually started, it immediately terminates."
//
//
// The following code demonstrates that this specification is not implemented.
// The thread t1 is stopped, then started. It executes to completion and is not
// "terminated immediately", as per the API documentation.
//
// To compile: javac Bug1.java
//
public class Bug1 implements Runnable
{
public boolean hasRun;
public Bug1()
{
hasRun = false;
}
public void run()
{
try {
hasRun = true;
} finally {
}
}
private static void test()
{
Thread t1;
Bug1 b1;
b1 = new Bug1();
t1 = new Thread(b1);
t1.stop();
t1.start();
try {
t1.join();
} catch (InterruptedException e) {
}
if (b1.hasRun) {
System.err.println("failed...t1 executed after a stop()");
} else {
System.err.println("passed");
}
}
public static void main(String args[])
{
test();
}
}
This was originally discovered on AIX 1.1.6, but also occurs on NT JDK 1.1.6,
1.1.7A, 1.2beta4H.
======================================================================
- duplicates
-
JDK-4145906 Thread.stop() not implemented according to documentation
- Closed
- relates to
-
JDK-4519200 (thread) Started thread does not terminate immediately if it was stopped before
- Resolved