JVM 1.4.1 and stopping threads
I am a consultant and we have a large multi-national company which runs jvm version 1.4.1. for the application, plus for several other applications.
The problem they are experiencing, and upgrading to a newer JVM version is currently NOT an option, is that a call to the Thread.stop() method does not actually stop the threads, but instead they keep running until the JVM is killed. The CPU usage, because the stopping of the threads is not successful, goes very quickly to close to 100% and stays there. Tests indicate that this problem does not exist with higher jvm versions, however again, upgrade is currently not an option.
Does anyone know of a successful workaround for this thread stopping problem in the jvm version 1.4.1.?
Feedback is appreciated.
[783 byte] By [
usr_techa] at [2007-10-3 0:32:13]

stop
@Deprecated
public final void stop()
Deprecated. This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack). If any of the objects previously protected by these monitors were in an inconsistent state, the damaged objects become visible to other threads, potentially resulting in arbitrary behavior. Many uses of stop should be replaced by code that simply modifies some variable to indicate that the target thread should stop running. The target thread should check this variable regularly, and return from its run method in an orderly fashion if the variable indicates that it is to stop running. If the target thread waits for long periods (on a condition variable, for example), the interrupt method should be used to interrupt the wait. For more information, see Why are Thread.stop, Thread.suspend and Thread.resume Deprecated?.
Hi,
I have not used Thread.stop() since about JDK 1.0.2 since it is so dangerous.
If you have access to the code and it does not have too many:
catch(InterruptedException e) { /* Ignore */ }
blocks then converting to use Thread.interrupt() can be a good alternative, and also allows you to cleanly get code out of I/O calls, etc.
For example, look at how the main servlet thread interrupt()s the read-ahead thread in this servlet:
http://gallery.hd.org/_javadoc/src-html/org/hd/d/pg2k/webSvr/exhibit/ExhibitServlet.html#line.442
Rgds
Damon