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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -