File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exception propagation and Threads........ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exception propagation and Threads........" Watch "Exception propagation and Threads........" New topic
Author

Exception propagation and Threads........

Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

For a normal program follow, if a Runtime Exception is thrown, the application stopped there the further execution, if the exception isn't handled. It's OK. For Example


In the above code, the 4th line won't be executed, because there is a exception is thrown at the line 9.

But for execution of Threads, What is the internal structure of this exception?


For this code, the output is,

run.Exception in thread "Thread-0" java.lang.RuntimeException: Problem.
at ThreadException.run(ThreadException.java:4)
at java.lang.Thread.run(Thread.java:619)
End of Method.


How this exception is handled? Thanks in Advanced!


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

The exception is not handled. That's why you got the stack trace. If an exception is not handled, then only the Thread in which the exception occurred is stopped, not the whole JVM. Any other running Threads can continue running in the JVM...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Abimaran Kugathasan wrote:
How this exception is handled?
Thanks in Advanced!


Sorry for that wrong statement, It should be "How this execution happens?

Thanks Ankit for quick replay..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception propagation and Threads........