java - SCJP: Program not terminating after uncaught exception -
public class threads2 implements runnable { public void run() { system.out.println("run."); throw new runtimeexception("problem"); } public static void main(string[] args) { thread t = new thread(new threads2()); t.start(); system.out.println("end of method."); } } i predicted output
run. //exception but showing output as,
run exception end of method (or)
run end of method exception i wonder, once exception has occurred program terminate, right?
no, program not terminate, thread does.
when thread throws uncaught exception terminates. main thread continues running.
Comments
Post a Comment