Considering this code, can I be absolutely sure that the finally
block always executes, no matter what something()
is?
try
Yes, finally
will be called after the execution of the try
or catch
code blocks.
The only times finally
won't be called are:
System.exit()
Runtime.getRuntime().halt(exitStatus)
try
or catch
blockkill -9
on UNIXfinally
block is going to be executed by a daemon thread and all other non-daemon threads exit before finally
is called