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

(thread) Bug 4082713 is not a duplicate of 4145910 and is not fixed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.8
    • core-libs
    • generic
    • generic

      Name: vi73552 Date: 03/24/99


      Bug 4082713 concerns the problem that, contrary to the specification, you can start() a thread after invoking stop() on it.

      Bug 4082713 is incorrectly labelled as a duplicate of 4145910 but they are quite different. The only relationship between them is the incorrect usage of the stillborn and privateinof flags in start(), stop() and isAlive(). They are different symptoms of the same underlying problem.

      When stop() is invoked it should set the stillborn flag to true. When start() is invoked it should check the stillborn flag and ignore the request if stillborn is true.

      The following code demonstrates that you can start a thread that was previously stopped.

      public class testStartStoppedThread {

      public static void main(String[] args){

      Thread t = new Thread( new Runnable() {
         public void run(){
            for (;;) {
               try {
                 System.out.println("Thread running");
                 Thread.sleep(500);
               }
               catch(InterruptedException ex){}
            }
         }
       });
      System.out.println("invoking t.stop()");
      t.stop();
      System.out.println("t is alive? " + t.isAlive() );
      System.out.println("invoking t.start()");
      t.start();
      System.out.println("t is alive? " + t.isAlive() );
      }
      }
      (Review ID: 56051)
      ======================================================================

            psoper Pete Soper (Inactive)
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: