Question: I read many times that Thread.stop is deprecated and it is
unsafe to use it. But never got good explanation why....
Answer: Because it is inherently unsafe. Stopping a thread causes it
to unlock all the monitors that it has locked. (The monitors are unlocked as the
ThreadDeath exception propagates up the stack.) If any of the objects previously
protected by these monitors were in an inconsistent state, other threads may now
view these objects in an inconsistent state. Such objects are said to be
damaged. When threads operate on damaged objects, arbitrary behavior can result.
This behavior may be subtle and difficult to detect, or it may be pronounced.
Unlike other unchecked exceptions, ThreadDeath kills threads silently; thus, the
user has no warning that his program may be corrupted. The corruption can
manifest itself at any time after the actual damage occurs, even hours or days
in the future.
http://java.sun.com/products/jdk/1.2/docs/guide/misc/threadPrimitiveDeprecation.html
*******************************************
Our older tips: March 22, 2001 - October 21, 2002READ
HERE
All published and not published on the site tips read
HERE
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.