Scheduling a Timer Task to Run Repeatedly

int delay = 5000; // delay for 5 sec. int period = 1000; // repeat every sec. Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { // Task here ... } }, delay, period);

Comments

6 Feb 2010 - 2:25am by Anonymous (not verified)

import ....?
Explanations nil.

11 Feb 2010 - 1:07am by Anonymous (not verified)

Use Eclipse, then you dont have to mess with imports.
The package that contains Timer and TimerTask is in java.util

9 Mar 2010 - 5:18am by Anonymous (not verified)

Nice

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.