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

runnung thread is not alive after stop()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • None
    • 1.1.8
    • core-libs
    • sparc
    • solaris_2.5.1

    Description

      Method Thread.stop() does not nesessary stops a thread but only causes
      an exception to be thrown on this thread. This exception can be intercepted
      and the thread can cantinue executionm

      However, in all jdk1.1.* releases, Thread.stop() immediately marks the object
      thread as not alive. Thread.stop(Throwable) does it too.

      Testcase:

      import java.io.PrintStream;

      class DeadOrAliveE extends Error {}

      public class DeadOrAlive {
        static PrintStream out=System.out;
        
        public static void main(String args[]) {

      Thread me=Thread.currentThread();

      try {
      // me.stop(new DeadOrAliveE());
      me.stop();
      // } catch (DeadOrAliveE e) {
      } catch (ThreadDeath e) {
      if (me.isAlive()) {
      out.println("OK");
      } else {
      out.println("isAlive()==false for running thread");
      }
      return;
      } catch (Throwable e) {
      out.println("wrong Throwable:"+e);
      }

      out.println("no Throwable thrown after stop");
        }

      }

      % javac DeadOrAlive.java
      % java -fullversion
      java full version "JDK1.1.8M"
      % java DeadOrAlive
      isAlive()==false for running thread

      Attachments

        Issue Links

          Activity

            People

              jjb Josh Bloch
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: