File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Suggestions for catching runtime in run function

 
John Vorwald
Ranch Hand
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • 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



 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • 1
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ranganathan.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic