JDK-6562203 : (thread) Thread doesn't terminate immediately if it was stopped before start
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-05-25
  • Updated: 2013-05-28
  • Resolved: 2011-04-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b132Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
The CR 4519200 "(thread) Started thread does not terminate immediately if it was stopped before"
has a Fix Delivered state, but the following example still fails:
--------------------------------------------------------------
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;
  }
}
--------------------------------------------------------------

The evalutation of CR 4519200 contains the following note:
"The latency of thread stoppage will typically be 1-3 bytecodes...".

So either the spec should mention stoppage latency or implementation
should be fixed to terminate stopped thread immediately.

Comments
EVALUATION Changeset: afa89f8ab9c8 Author: chegar Date: 2011-02-16 12:38 +0000 URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/afa89f8ab9c8 6562203: Thread doesn't terminate immediately if it was stopped before start Reviewed-by: dholmes, alanb ! src/share/classes/java/lang/Thread.java - test/java/lang/Thread/StopBeforeStart.java
16-02-2011

EVALUATION CR 6566340 fixes the stillborn flag in the vm. So now the vm itself will correctly handle threads that have been stopped before start. This CR will be used to remove stopBeforeStart logic that was added to java.lang.Thread, by CR 4519200, that partially fixed this in JDK 6.
25-01-2011

EVALUATION Yes.
03-06-2007