• Post Reply Bookmark Topic Watch Topic
  • New Topic

catch exception from thread  RSS feed

 
Peter Curila
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I start second thread from main thread .This second thread throws unchecked exception. How can I catch exception or detect that something was wrong.
I can not to get into branch "Everything is OK".



Main start
Thread start
Exception in thread "Thread-0" java.lang.IllegalStateException: Error
at ExceptionThread.run(ExceptionThread.java:4)
Process exited with exit code 0.
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason you never get to the catch() in main() is that there is no exception in the main thread.

You cannot "get to" code in another thread.

You seem to be lacking a basic understanding of threading principles (most people never use threads so you're among the masses.)

Go over to Sun's web site or any of the other helpful places and take a tutorial on threads.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!