0

i have a GUI application that needs to check that it is connected to a database every 30 - 60 secs. can this be done with java threads or do i need to look somewhere different. obviously i need the application to be fully useable whilst it is performing this.

2
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by Fungus1487
0

Best use a Timer and TimerTask, that's what they're there for after all :)

Creating your own mechanism using threads (which a Timer no doubt uses under the hood) is certainly possible, but why do things the hard way?

Do mind that whatever option you choose there are no exact guarantees for the interval you want. What you'll actually get will depend on outside influences (operating system timeslicing etc.) but with a Timer the JVM will try what it can to get as close as it can, while with your own threads it will only guarantee a minimum sleep period.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.