JDK-6195215 : (spec thread) Thread.stop() works differently from what API document says
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-11-15
  • Updated: 2017-05-19
  • Resolved: 2005-09-02
Related Reports
Duplicate :  
Description
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."
However, they found the following test case.

--- Test Case ---->

public class ThreadDeathBeforeStart extends Thread{
   public static void main(String[] args) throws Exception {
      Thread t = new ThreadDeathBeforeStart();
       t.stop();
       t.start();
}

public void run() {
   System.out.println("aaa");
}

<--- Test Case End -----

The test case outputs "aaa". That does not seem to represent what API documents says.

Ex. )

K:\shares2\thread-stop-behavior-strange>java -showversion ThreadDeathBeforeStart
java version "1.6.0-ea"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b11)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b11, mixed mode)

aaa

K:\shares2\thread-stop-behavior-strange>

CONFIGURATION :
  OS  : WindowsXP(SP1, Japanese)
  JRE : 1.4.2/5.0/6.0b11

###@###.### 2004-11-15 07:37:57 GMT

Comments
EVALUATION In this case the straight forward thing to do is simply strike the specification statement in question. This will bring the spec in line with implementations that have been ignoring this detail all along, while keeping the door open for variant implementations (i.e. the new spec will not disallow their behavior).
02-09-2005

EVALUATION Java has behaved this way since forever (at least since 1.1). Tiger comes with Executors that allow cancellation. ###@###.### 2004-12-15 17:37:05 GMT
15-12-2004