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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using timers

Status
Not open for further replies.

Bujitsu

MIS
Oct 23, 2003
67
AU
Hi,

I am trying to understand how to create a timer to fire every twenty seconds. (I plan to use this in a thread.)
I'm not sure how to start. Should I use the the timer.schedule function??

Any assitance would be great.

Cheers.
 
In the future please post plain Java questions in forum269 - this forum is for J2EE questions only.

Create a class that extends TimerTask.
Implement the run() method.

Then schedule the task :

MyTimerTask task = new MyTimerTask();
Timer timer = new Timer(true);
timer.schedule(task, 0L, 20000L);

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Sorry for posting to the wrong forum.

Thanks for the responce.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top