I used to think that when an exception happened, the whole java application will be terminated. For example, I write a test function to test my idea.
public void
my question is ,in what condition ,a exception will cause the whole application to be terminated?
It won't ever. Only System.exit() causes the whole program to terminate (and a JVM crash)
Think of an Exception and like a powerful break;
which can break out of methods. A break could result in a loop exiting and if the last loop in the only non daemon thread, the program will exit. But it doesn't cause it, even though it might be the last thing you see before you program dies.