Running multiple TimerTask

Hi All

I want to be able to run multiple TimerTasks.

The following snippet of code has only Task2 executed every 5 seconds. Task1 never gets executed. (I use jdk1.4)

import java.util.Timer;

import java.util.TimerTask;

publicclass Scheduler{

publicstaticvoid main(String[] args){

TimerTask task1 =new MyTask();

TimerTask task2 =new MyTask2();

Timer timer =new Timer();

timer.schedule(task1, 1000);

timer.schedule(task2, 500);

}

}

Can you please tell me how to schedule multiple tasks.

Thanks

bib

[1038 byte] By [bib1a] at [2007-11-27 1:25:46]
# 1
Hi, Create a Timer for each TimerTask.Hope that help,Jack
jack@square6a at 2007-7-12 0:19:11 > top of Java-index,Java Essentials,New To Java...