先来看看源代码中关于 cancel的注释
/**
* Cancels the {@code Timer} and all scheduled tasks. If there is a
* currently running task it is not affected. No more tasks may be scheduled
* on this {@code Timer}. Subsequent calls do nothing.
*/
public void cancel() {
impl.cancel();
}
timer对象调用cancel后,再进行schedule任务调用会导致Crash
例如
Timer timer= new Timer();
timer.cancel();
timer.schedule(...) //crash
需要重新new timer对象