當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。