IntelliJ Java IDE
The moose likes Threads and Synchronization and the fly likes Threading Process Question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Threading Process Question" Watch "Threading Process Question" New topic
Author

Threading Process Question

Grant Morris
Greenhorn

Joined: Aug 08, 2001
Posts: 8
I'm trying to design a process for an application using threads. I am having trouble figuring out the best way to do things. I have an application that will connect to a database, then periodically check for updates and send messages based on the updates. I am using a TimerTask object to check for and process the updates.
My goal is to make the application recover from database disconnects and message errors by 1.) closing the db connection and re-connecting, and 2.) stop the process that checks for updates and restart it.
I thought that I could do this using some threads and having an "outer/parent" thread connect to the database and start the TimerTask process and then wait until the TimerTask process encounters and error and notifies it to restart. However, I'm having trouble because once I cancel the process, I can't get it to run again even though I re-instantiate the object. (I know cancel() keeps it from running again, but I though if I could re-instantiate it, that it would create a new object and thus run again.)
Any ideas on how to accomplish this. Thanks for the help.
Grant Morris
Greenhorn

Joined: Aug 08, 2001
Posts: 8
Nevermind, I think I got it figured out.
 
 
subject: Threading Process Question
 
Threads others viewed
check if server is online
Making a database connection inside a thread
Record Caching, Reading Records
How to make my JMS Subscriber more scalable?
JPA update not available to some successive queries
IntelliJ Java IDE