finally 中的代码⼀定会执⾏吗?

19 阅读1分钟

不⼀定的!在某些情况下,finally 中的代码不会被执⾏。

  • 1.程序所在的线程死亡。
  • 2.关闭 CPU。
  • 3.finally 之前虚拟机被终⽌运⾏的话