Runtime exception not terminating the programm [closed]

馋奶兔 提交于 2019-12-23 05:17:40

问题


As per my little-bit java knowledge Program supposed to be terminated after it throws runtime exception.

But in my application after throwing runtime exception it is not terminating ,and as i am executing it on linux i have to use ctrl+c to terminate it, Otherwise it just do not terminate.

I am creating jar on windows sytem and copy paste it in linux.

Also i have logging enabled in my application.

Update: I am not catching any exception No multithreading is used.


回答1:


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).



来源:https://stackoverflow.com/questions/7635501/runtime-exception-not-terminating-the-programm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!