• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

catch exception from thread

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic