...
Wiki Markup |
---|
Invoking {{Thread.stop()}} results in the release of all the locks a thread has acquired, which may corrupt the state of the object. The thread could catch the {{ThreadDeath}} exception and use a {{finally}} block in an attempt to repair the inconsistent object. However, this requires careful inspection of all the synchronized methods and blocks because a {{ThreadDeath}} exception can be thrown at any point during the thread's execution. Furthermore, code must be protected from {{ThreadDeath}} exceptions that may result when executing {{catch}} or {{finally}} blocks \[[Sun 1999|AA. JavaBibliography#Sun References#Sun 99]\]. |
More information about deprecated methods is available in guideline MET15-J. Do not use deprecated or obsolete methods. Also, refer to guideline EXC09-J. Prevent inadvertent calls to System.exit() or forced shutdown for information on preventing data corruption when the JVM is shut down abruptly.
...
Wiki Markup |
---|
However, the {{Thread.stop()}} method causes the thread to stop what it is doing and throw a {{ThreadDeath}} exception. All acquired locks are subsequently released \[[API 2006|AA. Java References#APIBibliography#API 06]\]. If the thread is in the process of adding a new integer to the vector when it is stopped, the vector may become accessible while it is in an inconsistent state. This can result in {{Vector.size()}} returning an incorrect element count, for example, because the element count is incremented after adding the element. |
...
Wiki Markup |
---|
\[[API 2006|AA. JavaBibliography#API References#API 06]\] Class Thread, method {{stop}}, interface ExecutorService \[[Sun 1999|AA. JavaBibliography#Sun References#Sun 99]\] \[[Darwin 2004|AA. Java References#DarwinBibliography#Darwin 04]\] 24.3 Stopping a Thread \[[JDK7 2008|AA. JavaBibliography#JDK7 References#JDK7 08]\] Concurrency Utilities, More information: Java Thread Primitive Deprecation \[[JPL 2006|AA. Java References#JPLBibliography#JPL 06]\] 14.12.1. Don't stop and 23.3.3. Shutdown Strategies \[[JavaThreads 2004|AA. JavaBibliography#JavaThreads References#JavaThreads 04]\] 2.4 Two Approaches to Stopping a Thread \[[Goetz 2006|AA. Java References#GoetzBibliography#Goetz 06]\] Chapter 7: Cancellation and shutdown |
...