• Post Reply Bookmark Topic Watch Topic
  • New Topic

exception handling in threads  RSS feed

 
satish kandi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we catch an exception thrown by a child thread's method in the parent thred's method which started the child.
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This forum is for Servlets questions. We have a forum for Threads, and I am going to move this post to the threads forum.

Mark
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really. The thing that comes closest is to use your own ThreadGroup subclass and overwrite uncaughtException.
 
Henry Wong
author
Sheriff
Posts: 22861
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ilja Preuss:
Not really. The thing that comes closest is to use your own ThreadGroup subclass and overwrite uncaughtException.


While the UncaughtException works, your options are limited in what you can do to recover. Another option is to create a wrapper runnable object that will call the child runnable object and catch any exceptions thrown. This wrapper will have more options because at the catch, the thread has not exited yet. A possible option is to set a flag, and call the child again.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!