public class Thread2 implements Runnable{
public void run(){
System.out.println("run");
throw new RuntimeException("Exception::::");
}
public static void main(
String args[]){
Thread2 tt=new Thread2();
Thread t=new Thread(tt);
t.start();
try {
t.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("main");
}
}
In this above prob the answere should come like
/*
run
Exception in thread "Thread-0" java.lang.RuntimeException: Exception::::
at Thread2.run(Thread2.java:6)
at java.lang.Thread.run(Unknown Source)
main
*/
but the output is like
/*
run
main
Exception in thread "Thread-0" java.lang.RuntimeException: Exception::::
at Thread2.run(Thread2.java:6)
at java.lang.Thread.run(Unknown Source)
*/
Can someone give a solution to this
//This Question is taken from TestsNow.com