• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic