Timer的使用方法:
private Timer timer = null;
private TimerTask task = null;
public void startTimer() {
timer = new Timer();
task = new TimerTask() {
@Override
public void run() {
//添加代码
}
};
timer.schedule(task, 100, 100);
}
public void stopTimer() {
if (timer != null) {
timer.cancel();
timer = null;
}
}