Each period of time run this code

Hello!

for example i have this function

public void runbytime(){

Date d = new Date();

/************************

here is my question

**************************/

}

In servlet i'll call runbytime() in the initiate, and this function will run a specific code (like http request).

Now, how can i make this function to run the "specific code " each couple of hours?

[421 byte] By [militiawarea] at [2007-11-26 18:08:19]
# 1

If you want to run some code on a regular basis, you can use a java.util.Timer and java.util.TimerTask.

But if you're doing this in a J2EE environment, check the docs -- some app servers I've seen have functionality to do this built-in, and probably specially tuned for the environment.

paulcwa at 2007-7-9 5:39:57 > top of Java-index,Java Essentials,Java Programming...