本文整理汇总了Java中java.util.concurrent.ScheduledThreadPoolExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy方法的典型用法代码示例。如果您正苦于以下问题:Java ScheduledThreadPoolExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy方法的具体用法?Java ScheduledThreadPoolExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy怎么用?Java ScheduledThreadPoolExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.ScheduledThreadPoolExecutor
的用法示例。
在下文中一共展示了ScheduledThreadPoolExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import java.util.concurrent.ScheduledThreadPoolExecutor; //导入方法依赖的package包/类
public void start() {
if (ses != null && !ses.isShutdown() && !ses.isTerminated()) {
return;
}
ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(4, new ThreadFactory() {
private final AtomicInteger threadNumber = new AtomicInteger(1);
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("TimerManager-Worker-" + threadNumber.getAndIncrement());
return t;
}
});
//this is a no-no, it actually does nothing..then why the fuck are you doing it?
stpe.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
ses = stpe;
}
示例2: getScheduledThreadPoolExecutor
import java.util.concurrent.ScheduledThreadPoolExecutor; //导入方法依赖的package包/类
/**
* Have shutdown actually means shutdown. Tasks that need to complete should use
* futures.
*/
public static ScheduledThreadPoolExecutor getScheduledThreadPoolExecutor(String name, UncaughtExceptionHandler handler, int poolSize, int stackSize) {
// HACK: ScheduledThreadPoolExecutor won't let use the handler so
// if we're using ExceptionHandlingRunnable then we'll be able to
// pick up the exceptions
Thread.setDefaultUncaughtExceptionHandler(handler);
ThreadFactory factory = getThreadFactory(name, handler);
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(poolSize, factory);
executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
return executor;
}
示例3: newScheduler
import java.util.concurrent.ScheduledThreadPoolExecutor; //导入方法依赖的package包/类
private static ListeningScheduledExecutorService newScheduler() {
final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(1);
scheduler.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
scheduler.setRemoveOnCancelPolicy(true);
return MoreExecutors.listeningDecorator(scheduler);
}