View Single Post
Old 08-23-2012, 03:43 PM   PM User | #1
guptaraul
New to the CF scene

 
Join Date: Aug 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
guptaraul is an unknown quantity at this point
Post Threads in Java, Help me out

This is my source code
[CODE]
public class Thread2 implements Runnable{
public void run()
{
System.out.println("run().");
throw new RuntimeException("Problem");
}


public static void main(String[] args) {
Thread t=new Thread(new Thread2());
t.start();
System.out.println("End of Method");

}
}
[CODE]
I am getting 2 different outputs

O/p 1.
[CODE]
End of MEthod
run().
Exception in thread "Thread-0" java.lang.RuntimeException: Problem
at Thread2.run(Thread2.java:6)
at java.lang.Thread.run(Unknown Source)
[CODE]
O/p 2.
[CODE]
Exception in thread "Thread-0" java.lang.RuntimeException: Problem
at Thread2.run(Thread2.java:6)
at java.lang.Thread.run(Unknown Source)
End of MEthod
run().
[CODE]

Can anyone help me, why am I getting two different outputs?
guptaraul is offline   Reply With Quote