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


Java ScheduledFuture.isDone方法代码示例

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

示例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");
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:28,代码来源:TaskCenter.java

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

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

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

示例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();
    }
}
 
开发者ID:redhat-developer,项目名称:che-starter,代码行数:46,代码来源:CheDeploymentConfig.java


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