Open source reader

Thursday, June 08, 2006

a *mini* working scheduler in 4 lines !

I learn every day something new ... Here is a mini quartz in a few lines of code using TimerTask

int delay = 5000; // delay for 5 sec.
int interval = 1000; // iterate every sec.
Timer timer = new Timer();

timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
// Task here ...
}
}, delay, interval);



Thanks javatips !

0 Comments:

Post a Comment

<< Home