Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4180576

Thread.start() doesn't throw IllegalThreadStateException

XMLWordPrintable

    • x86
    • solaris_2.4, windows_nt



      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%

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

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

            jloizeausunw Jane Loizeaux (Inactive)
            rfqsunw Rfq Rfq (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: