本文整理匯總了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);
}