This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!