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

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

问题描述

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

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

推荐答案

来自 Sun 教程

注意:如果JVM在尝试时退出或者正在执行捕获代码,然后finally 块可能不会执行.同样,如果线程执行try 或 catch 代码被中断或被杀死,finally 块可能不会即使应用程序作为一个整体继续.

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天全站免登陆