Does a finally block always run?

Warrior picture Warrior · Jan 21, 2009 · Viewed 78.3k times · Source

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

Answer

hhafez picture hhafez · Jan 21, 2009

from the Sun Tutorials

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.

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