상세 컨텐츠

본문 제목

[JAVA] throw new RuntimeExecpetion(); 하면은 해당 쓰레드 강제종료

JAVA\Spring

by 박집실 2022. 11. 27. 00:36

본문

 throw new RuntimeExecpetion() 쓰면은 해당 쓰레드는 강제종류된다. 멀티쓰레드인 상태일 때는 프로그램 자체가 종료되지 않고 해당 쓰레드만 종료된다.

 

단,

try{

...

ex) throw new Execption();

 

} catch(Execption e) {

   throw new RuntimeExecpetion(e);

 

Exception in thread "Thread-0" java.lang.RuntimeException: java.lang.Exception
at test.run(MyClass.java:21)
Caused by: java.lang.Exception
at test.run(MyClass.java:19)

 

하면은 런타임 예외와 감싼 예외까지 콘솔창에 예외 사유를 출력 후 종료됨

관련글 더보기