Solved

Need a thread to run every two hours...

Posted on 2006-07-20
4
237 Views
Last Modified: 2010-03-31
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
Comment
Question by:arctanx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 25 total points
ID: 17149891
util.Timer would probably be best
0
 
LVL 13

Accepted Solution

by:
kawas earned 50 total points
ID: 17149984
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
 
LVL 2

Author Comment

by:arctanx
ID: 17150130
I was actually thinking that myself.

thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17150136
:-)
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question