当前位置: 首页>>代码示例>>Java>>正文


Java ScheduledFuture.getDelay方法代码示例

本文整理汇总了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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:ReschedulingRunnable.java

示例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;
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:16,代码来源:DecayTaskManager.java

示例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);
}
 
开发者ID:daishicheng,项目名称:outcomes,代码行数:13,代码来源:Executors3.java

示例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);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:JmxCacheBuster.java

示例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);
    }
 
开发者ID:daishicheng,项目名称:outcomes,代码行数:12,代码来源:Main.java


注:本文中的java.util.concurrent.ScheduledFuture.getDelay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。