This content has been marked as final. Show 4 replies
That's correct. Read the javadoc on Timer and TimerTask.
There are also lots of examples if you google on those classes.
Can Anyone provide me any example..
i have a function in let say
public void xyz()
i want to run this "public void xyz()" every day evry one hour
can any one plzz help me..???
If you don't want to worry about the timing issues you can use the Executor classes. They provide lots of support for this kind of execution schedules. The following example creates an executor that schedules the job every 15 minutes.
Edited by: HugoT on Sep 14, 2007 2:39 PM
/** Create the executor thread pool that does the actual work */ ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(20); /** Create a task to be scheduled (must implement Runnable) */ MyTask task = new MyTask(); /** Schedule every 15 minutes, first run in 0 minutes */ stpe.scheduleAtFixedRate(task, 0, 15, TimeUnit.MINUTES);
Did the OP asked for any queue as well??