File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Problem with run method in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with run method in thread" Watch "Problem with run method in thread" New topic

Problem with run method in thread

nick angel
Ranch Hand

Joined: Dec 14, 2005
Posts: 39
Hello to everyone. I am newbie to java. I have a problem concerning threads.
I havewritten some code that will read from an html file and extract information adn then update an excel spreadsheet. The problem I am now having is that I do not wish the thread to exit if there is an exception throw. Rather I wish for it to wait a specified amount of time and then try the process again.

The relevent code is as follows:

I apologize if the code (which I am sure it is) is hard to understand. Ultimately what I wish to accomplish is to have the run method continue to execute even if there is an exception thrown. I have not included it here but where an exception would be thrown I would log the errors in a file.
As it stands the refresInterval variable is set to 15 minutes. And so every 15 minutes I update my excel spreadsheet. If however the line

throws ans exception the variable runit is set to false and the application halts (I don't want this).
I thought that I could solve this problem by not setting the variable to runit to false and setting the refreshInterval to 5 minutes for example for the applucation to start the entire process once again.

Some help would be greatlty appreciated as I am new to the topic of threads.
(Sorry if my explanations are not as clear as they should be).
Thank you in advance.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
So are you saying that even if you remove all "runit = false" statements the tread terminates if an exception is thrown? That would be odd. You're catching InfoException - maybe the exception that is happening is a different one?
I agree. Here's the link:
subject: Problem with run method in thread
It's not a secret anymore!