本文整理汇总了Java中rice.selector.TimerTask.scheduledExecutionTime方法的典型用法代码示例。如果您正苦于以下问题:Java TimerTask.scheduledExecutionTime方法的具体用法?Java TimerTask.scheduledExecutionTime怎么用?Java TimerTask.scheduledExecutionTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rice.selector.TimerTask
的用法示例。
在下文中一共展示了TimerTask.scheduledExecutionTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callAddTask
import rice.selector.TimerTask; //导入方法依赖的package包/类
private void callAddTask(TimerTask task) {
if (LOG.isDebugEnabled())
LOG.debug(String.format("addTask(%s)", task));
if (!piTimerQueue.add(task)) {
LOG.error("ERROR: Got false while enqueueing task " + task + "!");
} else {
task.setSelectorManager(this);
}
// need to interrupt thread if waiting too long in selector
if (select) {
// using the network
if (wakeupTime >= task.scheduledExecutionTime()) {
// we need to wake up the selector because it's going to sleep too long
wakeup();
}
} else {
// using the simulator
if (task.scheduledExecutionTime() == getNextTaskExecutionTime()) {
// we need to wake up the selector because we are now the newest
// shortest wait, and may be delaying because of a later event
wakeup();
}
}
}
示例2: addTask
import rice.selector.TimerTask; //导入方法依赖的package包/类
@Override
protected synchronized void addTask(TimerTask task) {
long now = timeSource.currentTimeMillis();
if ((task.scheduledExecutionTime() < now) && (timeSource instanceof DirectTimeSource)) {
// task.setNextExecutionTime(now);
if (logger.level <= Logger.WARNING) logger.logException("Can't schedule a task in the past. "+task+" now:"+now+" task.execTime:"+task.scheduledExecutionTime(), new Exception("Stack Trace"));
throw new RuntimeException("Can't schedule a task in the past.");
}
super.addTask(task);
}
示例3: getNextTaskExecutionTime
import rice.selector.TimerTask; //导入方法依赖的package包/类
@Override
public long getNextTaskExecutionTime() {
if (piTimerQueue.size() > 0) {
TimerTask next = (TimerTask) piTimerQueue.peek();
return next.scheduledExecutionTime();
}
return -1;
}