谁说finally块必须执行?

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/strivenoend/article/details/83622287

谁说finally块必须执行?不服来辩

try-catch-finally块中,finally块在以下几种情况将不会执行。

(1)finally块中发生了异常。

(2)程序所在线程死亡。

(3)在前面的代码中用了System.exit();

(4)关闭了CPU

猜你喜欢

转载自blog.csdn.net/strivenoend/article/details/83622287