finally块总是运行吗? [英] Does a finally block always run?

查看:155
本文介绍了finally块总是运行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何条件最终可能无法在java中运行?谢谢。

Is there any condition where finally might not run in java? Thanks.

推荐答案

来自 Sun教程


注意:如果JVM在try $ $退出时b $ b或catch代码正在执行,然后
finally块可能无法执行。
同样,如果执行
try或catch代码的线程被中断或
被终止,则finally块可能不会执行
,即使应用程序为
a whole仍在继续。

Note: If the JVM exits while the try or catch code is being executed, then the finally block may not execute. Likewise, if the thread executing the try or catch code is interrupted or killed, the finally block may not execute even though the application as a whole continues.

我不知道finally块不会执行的任何其他方式......

I don't know of any other ways the finally block wouldn't execute...

这篇关于finally块总是运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆