9 particular file as subject to the "Classpath" exception as provided
10 by Oracle in the LICENSE file that accompanied this code.
11
12 This code is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 version 2 for more details (a copy is included in the LICENSE file that
16 accompanied this code).
17
18 You should have received a copy of the GNU General Public License version
19 2 along with this work; if not, write to the Free Software Foundation,
20 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21
22 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 or visit www.oracle.com if you need additional information or have any
24 questions.
25 -->
26 <html lang="en">
27 <head>
28 <title>Java Thread Primitive Deprecation</title>
29 <link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
30 </head>
31 <body>
32 <h2>Java Thread Primitive Deprecation</h2>
33 <hr>
34 <h3>Why is <code>Thread.stop</code> deprecated?</h3>
35 <p>Because it is inherently unsafe. Stopping a thread causes it to
36 unlock all the monitors that it has locked. (The monitors are
37 unlocked as the <code>ThreadDeath</code> exception propagates up
38 the stack.) If any of the objects previously protected by these
39 monitors were in an inconsistent state, other threads may now view
40 these objects in an inconsistent state. Such objects are said to be
41 <i>damaged</i>. When threads operate on damaged objects, arbitrary
42 behavior can result. This behavior may be subtle and difficult to
43 detect, or it may be pronounced. Unlike other unchecked exceptions,
44 <code>ThreadDeath</code> kills threads silently; thus, the user has
45 no warning that his program may be corrupted. The corruption can
46 manifest itself at any time after the actual damage occurs, even
47 hours or days in the future.</p>
48 <hr>
49 <h3>Couldn't I just catch the <code>ThreadDeath</code> exception
|
9 particular file as subject to the "Classpath" exception as provided
10 by Oracle in the LICENSE file that accompanied this code.
11
12 This code is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 version 2 for more details (a copy is included in the LICENSE file that
16 accompanied this code).
17
18 You should have received a copy of the GNU General Public License version
19 2 along with this work; if not, write to the Free Software Foundation,
20 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21
22 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 or visit www.oracle.com if you need additional information or have any
24 questions.
25 -->
26 <html lang="en">
27 <head>
28 <title>Java Thread Primitive Deprecation</title>
29 <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
30 </head>
31 <body>
32 <h2>Java Thread Primitive Deprecation</h2>
33 <hr>
34 <h3>Why is <code>Thread.stop</code> deprecated?</h3>
35 <p>Because it is inherently unsafe. Stopping a thread causes it to
36 unlock all the monitors that it has locked. (The monitors are
37 unlocked as the <code>ThreadDeath</code> exception propagates up
38 the stack.) If any of the objects previously protected by these
39 monitors were in an inconsistent state, other threads may now view
40 these objects in an inconsistent state. Such objects are said to be
41 <i>damaged</i>. When threads operate on damaged objects, arbitrary
42 behavior can result. This behavior may be subtle and difficult to
43 detect, or it may be pronounced. Unlike other unchecked exceptions,
44 <code>ThreadDeath</code> kills threads silently; thus, the user has
45 no warning that his program may be corrupted. The corruption can
46 manifest itself at any time after the actual damage occurs, even
47 hours or days in the future.</p>
48 <hr>
49 <h3>Couldn't I just catch the <code>ThreadDeath</code> exception
|