1 <!doctype html>
2 <!--
3 Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
4 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
6 This code is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License version 2 only, as
8 published by the Free Software Foundation. Oracle designates this
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
329 repaint();
330 }
331 }
332
333 public synchronized void stop() {
334 blinker = null;
335 notify();
336 }
337 </pre>
338 If the <code>stop</code> method calls <code>Thread.interrupt</code>, as
339 described above, it needn't call <code>notify</code> as well, but it
340 still must be synchronized. This ensures that the target thread
341 won't miss an interrupt due to a race condition.
342 <hr>
343 <h3>What about <code>Thread.destroy</code>?</h3>
344 <code>Thread.destroy</code> was never implemented and has been
345 deprecated. If it were implemented, it would be deadlock-prone in
346 the manner of <code>Thread.suspend</code>. (In fact, it is roughly
347 equivalent to <code>Thread.suspend</code> without the possibility
348 of a subsequent <code>Thread.resume</code>.)
349 <hr>
350 <h3>Why is <code>Runtime.runFinalizersOnExit</code>
351 deprecated?</h3>
352 Because it is inherently unsafe. It may result in finalizers being
353 called on live objects while other threads are concurrently
354 manipulating those objects, resulting in erratic behavior or
355 deadlock. While this problem could be prevented if the class whose
356 objects are being finalized were coded to "defend against" this
357 call, most programmers do <i>not</i> defend against it. They assume
358 that an object is dead at the time that its finalizer is called.
359 <p>Further, the call is not "thread-safe" in the sense that it sets
360 a VM-global flag. This forces <i>every</i> class with a finalizer
361 to defend against the finalization of live objects!</p>
362 <p><!-- Body text ends here --></p>
363 </body>
364 </html>
|
1 <!doctype html>
2 <!--
3 Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
4 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
6 This code is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License version 2 only, as
8 published by the Free Software Foundation. Oracle designates this
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
329 repaint();
330 }
331 }
332
333 public synchronized void stop() {
334 blinker = null;
335 notify();
336 }
337 </pre>
338 If the <code>stop</code> method calls <code>Thread.interrupt</code>, as
339 described above, it needn't call <code>notify</code> as well, but it
340 still must be synchronized. This ensures that the target thread
341 won't miss an interrupt due to a race condition.
342 <hr>
343 <h3>What about <code>Thread.destroy</code>?</h3>
344 <code>Thread.destroy</code> was never implemented and has been
345 deprecated. If it were implemented, it would be deadlock-prone in
346 the manner of <code>Thread.suspend</code>. (In fact, it is roughly
347 equivalent to <code>Thread.suspend</code> without the possibility
348 of a subsequent <code>Thread.resume</code>.)
349 <p><!-- Body text ends here --></p>
350 </body>
351 </html>
|