Saturday 19 July 2014

Is finally always execute in Java ?

In below cases finally may not execute
  1. finally block gets called regardless of what happens in the try block, unless you call System.exit method.
  2. If the JVM exits while the try or catch code is being executed, then the finally block will not execute.
  3. If the thread executing the try or catch code is interrupted or killed, the finally block will not execute even though the application as a whole continues.


                                                 Home

No comments:

Post a Comment