Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

process control with Timer class

Status
Not open for further replies.

gotchausa

Programmer
Jan 24, 2002
64
0
0
CA
I need to schedule a couple of tasks at different intervals. Would I need to create 2 separate TimerTask tasks to achieve this, each with its own run() method?

Many thx.
 
Yes, you can have a single class the defines the task but you need an instance for each task being timed.

does that help?
-pete
 
I'm doing something like

TimerTask a = new TimerTask();
run(){
...
}

TimerTask b = new TimerTask();
run(){
...
}

timer.schedule(a, ...)
timer.schedule(b, ..)

It seems to be working but I wonder if this is the correct and optimized way to code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top