| Author |
Suggestions for catching runtime in run function
|
John Vorwald
Ranch Hand
Joined: Sep 26, 2010
Posts: 139
|
|
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
|
 |
Ranganathan Kaliyur Mannar
Bartender
Joined: Oct 16, 2003
Posts: 915
|
|
|
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.
|
Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
|
 |
John Vorwald
Ranch Hand
Joined: Sep 26, 2010
Posts: 139
|
|
|
Thanks Ranganathan.
|
 |
 |
|
|
subject: Suggestions for catching runtime in run function
|
|
|