public abstract void run()
run
接口
Runnable
Thread.run()
public boolean cancel()
注意,调用此方法从一个定时器任务的run方法内绝对保证定时器任务不会再次运行。
此方法可以被重复调用;第二个和随后的调用没有影响。
public long scheduledExecutionTime()
这种方法通常是从一个任务的运行方法调用,以确定当前执行的任务是否足够及时,以保证执行预定的活动:
public void run() {
if (System.currentTimeMillis() - scheduledExecutionTime() >=
MAX_TARDINESS)
return; // Too late; skip this execution.
// Perform the task
}
这个方法通常不用于固定延迟执行重复任务的同时,为他们的计划执行时间可以随时间漂移,所以意义不明显。
Date.getTime()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.