United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4180576 : Thread.start() doesn't throw IllegalThreadStateException

Details
Type:
Bug
Submit Date:
1998-10-12
Status:
Closed
Updated Date:
2004-03-26
Project Name:
JDK
Resolved Date:
2003-04-25
Component:
hotspot
OS:
solaris_2.4,windows_nt
Sub-Component:
runtime
CPU:
x86
Priority:
P4
Resolution:
Duplicate
Affected Versions:
1.1.6,1.2.0
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

Description

Name: akC45999			Date: 10/12/98



The Java API spec chapter Class Thread reads :
...
 public void start()

 Causes this thread to begin execution; the Java Virtual Machine 
 calls the run method of this thread. 
 The result is that two threads are running concurrently: the 
 current thread (which returns from the call to the 
 start method) and the other thread (which executes its 
 run method).
 Throws: IllegalThreadStateException - if the thread was already started.
...

But test api/java_lang/Thread/start01/start0102 shows that when a thread 
is already finished IllegalThreadStateException is not thrown at incorrect 
invokation of Thread.start().

--------------------------------- start0102.java

import java.io.PrintStream;

public class start0102 extends Thread {

  boolean finish = true;

  public void run() {
	try {
		while(finish) Thread.sleep(10);
	} catch(InterruptedException e) {
	}
  }

  public static void main(String argv[]) {

	start0102 testThread = new start0102();
	testThread.start();

	try {
		testThread.start();
	} catch(IllegalThreadStateException e) {
	} 

	testThread.finish = false;
	try {
		testThread.join();
	} catch(InterruptedException e) {
	}

	try {
		testThread.start();
		System.out.println("Bad");
	} catch(IllegalThreadStateException e) {
		System.out.println("Ok " + e);
	} 
  }
}

---------------------------------- output

novo48% java -fullversion
java full version "JDK-1.2fcs-M"
novo26% dotest
Bad
novo26% 

======================================================================

======================================================================

                                    

Comments
EVALUATION

  This is indeed a bug.  It is one of a number of Thread-state maintenance problems.  

joshua.bloch@Eng 1998-10-13

------------------------------
This bug is a duplicate of 4773384 1.4 doesn't throw IllegalThreadStateException
and will be tracked under that bug number.

4773384 is committed to Tiger.

###@###.### 2003-04-25
-------------------------------
                                     
2003-04-25



Hardware and Software, Engineered to Work Together