• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

ThreadGroup style exception catcher

 
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Last year, I read about a style of exception handling that uses ThreadGroups. Is this covered in Robust Java ? Is this recommended ?
 
author
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pho Tek,

I'm guessing you're referring to overriding the ThreadGroup method uncaughtException, right? If so, I do discuss it in chapter 4 (Exceptions and Threading) on pages 64-65. I didn't get a chance to talk about the newer feature in JDK5.0 (the Thread's method setUncaughtExceptionHandler) since Tiger had not yet been released when I went to press.

The uncaughtException method can be a VERY effective way to build robust multithreaded code. And of course, it was formerly the only way a developer could address unchecked exceptions in a multithreaded environment. Of course, developers had to subclass the ThreadGroup to implement their own behavior... JDK5.0 has made it a lot easier to associate custom handling behavior with a specific thread by passing an implementation into the setter method mentionedd above.

Best wishes,
Steve
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am currently using ThreadGroup.uncaughtException in a Swing application. I did this in order to be able to present any runtime exception in a nice dialog that will further send us a mail.

--
:alex |.::the_mindstorm::.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ali Pope:
I am currently using ThreadGroup.uncaughtException in a Swing application. I did this in order to be able to present any runtime exception in a nice dialog that will further send us a mail.



We do something similar. Additionally, if the caught Throwable is an Error (the method is a misnomer, isn't it), we ask the user wether he wants to shut down the application.
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep Ilja exactly. Moreover there are a couple of custom runtimeexceptions that requires us to do some clean up behind .

--
:alex |.::the_mindstorm::.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic