Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with run method in thread

 
nick angel
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic