JDK-4241041 : runnung thread is not alive after stop()
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.1.8
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 1999-05-25
  • Updated: 2021-11-09
  • Resolved: 1999-06-09
Related Reports
Duplicate :  
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