本文整理汇总了Java中java.util.concurrent.ScheduledFuture.getDelay方法的典型用法代码示例。如果您正苦于以下问题:Java ScheduledFuture.getDelay方法的具体用法?Java ScheduledFuture.getDelay怎么用?Java ScheduledFuture.getDelay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.ScheduledFuture
的用法示例。
在下文中一共展示了ScheduledFuture.getDelay方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDelay
import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
@Override
public long getDelay(TimeUnit unit) {
ScheduledFuture<?> curr;
synchronized (this.triggerContextMonitor) {
curr = this.currentFuture;
}
return curr.getDelay(unit);
}
示例2: getRemainingTime
import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
/**
* Gets the remaining time of the specified character's decay task.
* @param character the character
* @return if a decay task exists the remaining time, {@code Long.MAX_VALUE} otherwise
*/
public long getRemainingTime(L2Character character)
{
final ScheduledFuture<?> decayTask = _decayTasks.get(character);
if (decayTask != null)
{
return decayTask.getDelay(TimeUnit.MILLISECONDS);
}
return Long.MAX_VALUE;
}
示例3: test1
import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
private static void test1() throws InterruptedException {
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
Runnable task = () -> System.out.println("Scheduling: " + System.nanoTime());
int delay = 3;
ScheduledFuture<?> future = executor.schedule(task, delay, TimeUnit.SECONDS);
TimeUnit.MILLISECONDS.sleep(1337);
long remainingDelay = future.getDelay(TimeUnit.MILLISECONDS);
System.out.printf("Remaining Delay: %sms\n", remainingDelay);
}
示例4: clearJmxCache
import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
/**
* For JMX to forget about all previously exported metrics.
*/
public static void clearJmxCache() {
//If there are more then 100 ms before the executor will run then everything should be merged.
ScheduledFuture future = fut.get();
if ((future != null && (!future.isDone() && future.getDelay(TimeUnit.MILLISECONDS) > 100))) {
// BAIL OUT
return;
}
future = executor.getExecutor().schedule(new JmxCacheBusterRunnable(), 5, TimeUnit.SECONDS);
fut.set(future);
}
示例5: scheduled
import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
private static void scheduled() throws InterruptedException {
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
Runnable task = () -> System.out.println(" Scheduling: " + System.currentTimeMillis());
ScheduledFuture<?> future = executor.schedule(task, 3, TimeUnit.SECONDS);
long remainingDelay = future.getDelay(TimeUnit.MILLISECONDS);
System.out.printf("Remaining Delay: %sms", remainingDelay);
}