1 <!doctype html> |
1 <!doctype html> |
2 <!-- |
2 <!-- |
3 Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. |
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. |
4 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 |
5 |
6 This code is free software; you can redistribute it and/or modify it |
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 |
7 under the terms of the GNU General Public License version 2 only, as |
8 published by the Free Software Foundation. Oracle designates this |
8 published by the Free Software Foundation. Oracle designates this |
344 <code>Thread.destroy</code> was never implemented and has been |
344 <code>Thread.destroy</code> was never implemented and has been |
345 deprecated. If it were implemented, it would be deadlock-prone in |
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 |
346 the manner of <code>Thread.suspend</code>. (In fact, it is roughly |
347 equivalent to <code>Thread.suspend</code> without the possibility |
347 equivalent to <code>Thread.suspend</code> without the possibility |
348 of a subsequent <code>Thread.resume</code>.) |
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> |
349 <p><!-- Body text ends here --></p> |
363 </body> |
350 </body> |
364 </html> |
351 </html> |