timer,TimerTask结合使用来完成定时任务,需要注意的是只要一个timer任务被意外中止,则整个任务被中止。可以采用线程代替这种应用。
public class timerapp
extends TimerTask
{
timerapp(){
}
public void run(){
}
}
Timer sss = new Timer();
sss.schedule(new timerapp,100,10000);
syntax:
void schedule(TimerTask task, long delay, long period)
Schedules the specified task for repeated fixed-delay execution, beginning after the specified delay.