• 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

Suggestions for catching runtime in run function

 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm new to thread programming, and am kind of working on a monkey see monkey do approach.
I have a reasonably sized program that runs multiple threads, and am wondering how to catch the runtime exceptions.
The code below catches the runtime error and displays the message in a gui. I'm running the program in eclipse, and have noticed that when the dialog box is closed, the process continues to run. How should the program be modified to stop running when the exception dialog is closed?
I thought that adding Thread.currentThread().interrupt(); to the close action listener would do the trick, but the process is still running...

Cheers,
John



 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your class 'ThreadExceptionHandler' is just a Runnable and not a Thread. You are not starting a thread anywhere. By calling SwingUtilities.invokeLater, you are just adding a piece of Runnable to be placed in the EDT queue (Swing's Event Thread). The process continues to be running because, in the close button, you only make the dialog invisible. Instead, call dispose() on the dialog to close it. Then the process will end.
 
John Vorwald
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ranganathan.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic