Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Polling from my java class vs. using polling service  RSS feed

 
Monty Guppy
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a java class that needs to be run after every 10 minutes to check for a DB change and accordingly perform certain functions. I am unable to decide the pros and cons of achieving this either by: 1) writing a *.bat and scheduling it using scheduler, or 2) to use a thread that sleeps according the the wait() function.
I have an inclination to use the latter, but the problem is that if the DB goes down, then the thread might be broken.
I would appreciate if anybody can give their thoughts on the above, especially in the use of method 2. Any code sample would be super.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using JDK 1.3 or better, look into java.util.Timer and java.util.TimerTask.
- Peter
 
Monty Guppy
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am forced to use only JDK 1.2 becasue of app server limitations.
Thanks
Originally posted by Peter den Haan:
If you're using JDK 1.3 or better, look into java.util.Timer and java.util.TimerTask.
- Peter

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!