Tuesday, 15 January 2013

When finally block is NOT called?


Finally block is NOT called in following conditions
  • If the JVM exits while the try or catch code is being executed, then the finally block may not execute. This may happen due to System.exit() call.
  • 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.
  • If a exception is thrown in finally block and not handled then remaining code in finally block may not be executed.
  • If there is infinite loop, or deadlock then also finally block will not get executed

No comments:

Post a Comment