java定时器Timer使用
public?class?MyTimer?{
??
??private?Timer?timer?=?null;
??public?void?startTimer?{
????timer?=?new?Timer(true);
????//设置任务计划,启动和间隔时间
????timer.schedule(new?MyTask(),?0,?86400000);
??}
??public?void?tmerDestroyed()?{
????timer.cancel();
??}
??
}
?
import?java.util.TimerTask;
public?class?MyTask?extends?TimerTask?{
??public?void?run()?{
????//?System.out.println("call?at?"?+?(new?Date()));
????//?TODO?此处添加具体任务代码
??}
}
?
?
?