java - 错误下ThreadDeath的使用

标签 java multithreading error-handling

ThreadDeath在Throwable下的Error下的作用是什么?

最佳答案

An instance of ThreadDeath is thrown in the victim thread when the stop method with zero arguments in class Thread is called.

An application should catch instances of this class only if it must clean up after being terminated asynchronously. If ThreadDeath is caught by a method, it is important that it be rethrown so that the thread actually dies.

The top-level error handler does not print out a message if ThreadDeath is never caught.

The class ThreadDeath is specifically a subclass of Error rather than Exception, even though it is a "normal occurrence", because many applications catch all occurrences of Exception and then discard the exception.

Since: JDK1.0

来源:Java API
示例:Link

关于java - 错误下ThreadDeath的使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3838903/

相关文章:

java - 在java中使用hashmap创建嵌套映射来完成嵌套数组但不起作用

c++ - Windows 线程-C++

java - Java线程: 'join' froze my program

python - 除以0时,我希望它打印给定的文本

java - 使用 Java EE 6 注释的 Servlet 过滤?

java - Jackson解析器异常: unexpected Character

java - 如何在 iText (Java) 中垂直剪辑文本 anchor

c++ - JNI 使用多线程从 C++ 调用 Java

javascript - 在带有异步的 Nodejs 中使用自定义错误

python - 使用 cElementTree : dealing with errors and line number in the file 在 python 中解析 XML 文件