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

1.4 doesn't throw IllegalThreadStateException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 1.1.6, 1.2.0, 1.3.0, 1.3.1, 1.4.1
    • Fix Version/s: 5.0
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      tiger
    • CPU:
      x86, sparc
    • OS:
      generic, linux, solaris_2.4, solaris_8, windows_nt, windows_2000
    • Verification:
      Verified

      Description

      JDK 1.4 does not throw the IllegalThreadStateException if the thread's function
      start() is called twice. Strangely enough, it seems as if the 1.4 JVM optimized
      the loop so that the dummy1's start() is only called once.

      I can make the program to throw IllegalThreadStateException by:

      - Run it with jdk 1.2 or lower.

      - Comment out the dummy2 instantiation and start i.e.
        // (new dummy2()).start();

      Please see the following attachment of program's output and code sample.

      --------------------------------------------------------------------------------

      %jdk1.4 test
      Gonna call start()!
      dummy1 done!
      Done calling start()!
      Gonna call start()!
      dummy2 done!
      Done calling start()!
      dummy2 done!

      % jdk1.2 test
      Gonna call start()!
      Done calling start()!
      Gonna call start()!
      Exception in thread "main" java.lang.IllegalThreadStateException
      at java.lang.Thread.start(Native Method)
      at test.<init>(Compiled Code)
      at test.main(Compiled Code)
      dummy1 done!
      dummy2 done!

      --------------------------------------------------------------------------------

      public class test {
          private dummy1 t1 = new dummy1();

          public static void main(String args[]) {
      new test();
          }

          test() {
      for (int j = 0; j < 2; j++) {
      System.out.println("Gonna call start()!");
      t1.start();
      (new dummy2()).start();
      System.out.println("Done calling start()!");
      }
          }

          public class dummy1 extends Thread {
      public void run() {
      System.out.println("dummy1 done!");
      }
          }

          public class dummy2 extends Thread {
      public void run() {
      System.out.println("dummy2 done!");
      }
          }

      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jloizeausunw Jane Loizeaux (Inactive)
              Reporter:
              rphamsunw Roger Pham (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: