I have always thought that finally blocks are executed in any circumstances; but that wasn't true!
public class Test {
public static void main(String[] args) {
try {
System.out.println("Hi");
System.exit(0);
} finally {
System.out.println("Hi2");
}
}
}
In this case System.exit method halts the execution of the current thread. The presence of a finally clause does not give the thread special permission to continue executing.