aspose file tools*
The moose likes Threads and Synchronization and the fly likes Suggestions for catching runtime in run function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Suggestions for catching runtime in run function" Watch "Suggestions for catching runtime in run function" New topic
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: 1075
    
  10

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Suggestions for catching runtime in run function
 
Similar Threads
Problem with opening new JPanel when separated into different classes
modal JDialog not responding to jbutton actionlistener?
How to get a new Frame on the center of the screen?
JDialog: How to set focus on second JButton?
Position etc. of Webstart windows