• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

Need a thread to run every two hours...

What is the best practice to use for this?

I need a Thread to do some work every two hours.

It will do the work, sleep, and wake up in two hours.

Again I need the best practice for this.

Should I use another Timer class, or just use Thread.sleep(7200) or 720000 or whatever it is...
0
arctanx
Asked:
arctanx
  • 2
2 Solutions
 
CEHJCommented:
util.Timer would probably be best
0
 
kawasCommented:
The class that CEHJ is what I have used:

Timer timer = new Timer();
timer.scheduleAtFixedRate(theTask, YOUR_STARTING_TIME_AS_DATE, FREQUENCY_IN_MILLI);

where theTask is a class that extends TimerTask.
0
 
arctanxAuthor Commented:
I was actually thinking that myself.

thanks
0
 
CEHJCommented:
:-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now