A RuntimeException
(or any Exception
or Throwable
) does not necessarily terminate your application.
It only terminates your applications if it's thrown on the only non-daemon thread and is not handled.
That means that if either another non-daemon thread is running or you catch the exception, the application will not be terminated.
This recent answer from me gives a summary of what happens (it's specifically about an OutOfMemoryError
, but the idea is the same).