本文整理汇总了Java中java.util.concurrent.ScheduledFuture.isDone方法的典型用法代码示例。如果您正苦于以下问题:Java ScheduledFuture.isDone方法的具体用法?Java ScheduledFuture.isDone怎么用?Java ScheduledFuture.isDone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.ScheduledFuture
的用法示例。
在下文中一共展示了ScheduledFuture.isDone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: close
import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
@Override
public void close() {
state.set(State.STOPPED);
if (!initialValueFuture.isDone()) {
initialValueFuture.cancel(false);
}
// Cancel any scheduled operations.
final ScheduledFuture<?> currentScheduleFuture = this.currentScheduleFuture;
if (currentScheduleFuture != null && !currentScheduleFuture.isDone()) {
currentScheduleFuture.cancel(false);
}
final CompletableFuture<?> currentWatchFuture = this.currentWatchFuture;
if (currentWatchFuture != null && !currentWatchFuture.isDone()) {
currentWatchFuture.cancel(false);
}
}
示例2: close
import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
public void close() {
System.out.println("TaskCenter closing");
this.monitoring.cancel(true);
// 停止所有定时任务
for (ScheduledFuture<?> sf : this.scheduledFutureList) {
if (!sf.isCancelled() || !sf.isDone()) {
sf.cancel(true);
}
}
this.scheduledFutureList.clear();
Iterator<Timer> iter = this.timers.values().iterator();
while (iter.hasNext()) {
Timer timer = iter.next();
timer.cancel();
}
this.timers.clear();
// 关闭滑动窗
this.slidingWindow.stop();
// 关闭线程池
this.mainExecutor.shutdown();
this.scheduledExecutor.shutdown();
System.out.println("TaskCenter closed");
}
示例3: run
import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
@Override
public void run() {
Iterator<ScheduledFuture<?>> iter = scheduledFutureList.iterator();
while (iter.hasNext()) {
ScheduledFuture<?> sf = iter.next();
if (sf.isCancelled() || sf.isDone()) {
// 删除已经结束的任务
iter.remove();
}
}
}
示例4: onInstanceDestroy
import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
@Override
public void onInstanceDestroy(Instance instance)
{
// Stop running spawn task
final ScheduledFuture<?> task = instance.getParameters().getObject("spawnTask", ScheduledFuture.class);
if ((task != null) && !task.isDone())
{
task.cancel(true);
}
instance.setParameter("spawnTask", null);
}
示例5: 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);
}
示例6: waitUntilDeploymentConfigIsAvailable
import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
private void waitUntilDeploymentConfigIsAvailable(final OpenShiftClient client, String namespace) {
final BlockingQueue<Object> queue = new ArrayBlockingQueue<Object>(1);
final Runnable readinessPoller = new Runnable() {
public void run() {
try {
if (isDeploymentAvailable(client, namespace)) {
queue.put(true);
return;
} else {
queue.put(false);
return;
}
} catch (Throwable t) {
try {
if (queue.isEmpty()) {
queue.put(false);
}
return;
} catch (InterruptedException e) {
}
}
}
};
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
ScheduledFuture<?> poller = executor.scheduleWithFixedDelay(readinessPoller, 0, 500, TimeUnit.MILLISECONDS);
executor.schedule(new Runnable() {
@Override
public void run() {
poller.cancel(true);
}
}, Integer.valueOf(startTimeout), TimeUnit.MILLISECONDS);
try {
while (!waitUntilReady(queue)) {
}
} finally {
if (!poller.isDone()) {
poller.cancel(true);
}
executor.shutdown();
}
}