利用Timer类设置一个task的schedule,会按照指定的时间间隔执行task
timer = new Timer(true);
timer.schedule(task, mlTimerUnit, mlTimerUnit); // set timer durationSDK说明:
void java.util.Timer.schedule(TimerTask task, long delay, long period)public void schedule (TimerTask task, long delay, long period)
Since: API Level 1
Schedule a task for repeated fixed-delay execution after a specific delay.Parameters
task the task to schedule.
delay amount of time in milliseconds before first execution.
period amount of time in milliseconds between subsequent executions. Throws
IllegalArgumentException if delay < 0 or period < 0.
IllegalStateException if the Timer has been canceled, or if the task has been scheduled or canceled.
timer = new Timer(true);
timer.schedule(task, mlTimerUnit, mlTimerUnit); // set timer durationSDK说明:
void java.util.Timer.schedule(TimerTask task, long delay, long period)public void schedule (TimerTask task, long delay, long period)
Since: API Level 1
Schedule a task for repeated fixed-delay execution after a specific delay.Parameters
task the task to schedule.
delay amount of time in milliseconds before first execution.
period amount of time in milliseconds between subsequent executions. Throws
IllegalArgumentException if delay < 0 or period < 0.
IllegalStateException if the Timer has been canceled, or if the task has been scheduled or canceled.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货