當前位置: 首頁>>代碼示例>>Java>>正文


Java ScheduledThreadPoolExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy方法代碼示例

本文整理匯總了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;
}
 
開發者ID:NovaStory,項目名稱:AeroStory,代碼行數:19,代碼來源:TimerManager.java

示例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;
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:17,代碼來源:ThreadUtil.java

示例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);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:8,代碼來源:MatchRealtimeScheduler.java


注:本文中的java.util.concurrent.ScheduledThreadPoolExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。