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


Java ThreadPoolExecutor.AbortPolicy方法代碼示例

本文整理匯總了Java中java.util.concurrent.ThreadPoolExecutor.AbortPolicy方法的典型用法代碼示例。如果您正苦於以下問題:Java ThreadPoolExecutor.AbortPolicy方法的具體用法?Java ThreadPoolExecutor.AbortPolicy怎麽用?Java ThreadPoolExecutor.AbortPolicy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.concurrent.ThreadPoolExecutor的用法示例。


在下文中一共展示了ThreadPoolExecutor.AbortPolicy方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getExecutor

import java.util.concurrent.ThreadPoolExecutor; //導入方法依賴的package包/類
public XExecutor getExecutor() {
    if (executor == null) {
        synchronized (DownloadThreadPool.class) {
            if (executor == null) {
                executor = new XExecutor(corePoolSize,
                        MAX_POOL_SIZE,
                        KEEP_ALIVE_TIME,
                        UNIT,
                        new PriorityBlockingQueue<Runnable>()/*無限容量的緩衝隊列*/,
                        Executors.defaultThreadFactory()/*線程創建工廠*/,
                        new ThreadPoolExecutor.AbortPolicy()/*繼續超出上限的策略,阻止*/);
            }
        }
    }

    return executor;
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:18,代碼來源:DownloadThreadPool.java

示例2: CountDownLatchHelper

import java.util.concurrent.ThreadPoolExecutor; //導入方法依賴的package包/類
public CountDownLatchHelper() {
    executes = Lists.newCopyOnWriteArrayList();
    data = Lists.newCopyOnWriteArrayList();
    threadPool= new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), Runtime.getRuntime().availableProcessors(),
            0L, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());

}
 
開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:9,代碼來源:CountDownLatchHelper.java

示例3: getExecutorService

import java.util.concurrent.ThreadPoolExecutor; //導入方法依賴的package包/類
public ExecutorService getExecutorService() {
    final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("search-thread-%d")
            .setDaemon(true).build();
    return new ThreadPoolExecutor(DEFAULT_THREAD_MAX, DEFAULT_THREAD_MAX,
            0L, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<>(1024), threadFactory, new ThreadPoolExecutor.AbortPolicy());

}
 
開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:9,代碼來源:FixedThreadPoolHelper.java

示例4: getExecutor

import java.util.concurrent.ThreadPoolExecutor; //導入方法依賴的package包/類
public XExecutor getExecutor() {
    if (executor == null) {
        synchronized (UploadThreadPool.class) {
            if (executor == null) {
                executor = new XExecutor(corePoolSize, MAX_IMUM_POOL_SIZE, KEEP_ALIVE_TIME, UNIT, //
                                         new PriorityBlockingQueue<Runnable>(),   //無限容量的緩衝隊列
                                         Executors.defaultThreadFactory(),        //線程創建工廠
                                         new ThreadPoolExecutor.AbortPolicy());   //繼續超出上限的策略,阻止
            }
        }
    }
    return executor;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:UploadThreadPool.java

示例5: getExecutor

import java.util.concurrent.ThreadPoolExecutor; //導入方法依賴的package包/類
public XExecutor getExecutor() {
    if (executor == null) {
        synchronized (DownloadThreadPool.class) {
            if (executor == null) {
                executor = new XExecutor(corePoolSize, MAX_POOL_SIZE, KEEP_ALIVE_TIME, UNIT, //
                                         new PriorityBlockingQueue<Runnable>(),   //無限容量的緩衝隊列
                                         Executors.defaultThreadFactory(),        //線程創建工廠
                                         new ThreadPoolExecutor.AbortPolicy());   //繼續超出上限的策略,阻止
            }
        }
    }
    return executor;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:DownloadThreadPool.java

示例6: createPool

import java.util.concurrent.ThreadPoolExecutor; //導入方法依賴的package包/類
protected synchronized static void createPool() {
    BlockingQueue<Runnable> workers = new LinkedBlockingQueue<>();
    RejectedExecutionHandler handler = new ThreadPoolExecutor.AbortPolicy();
    mDownloadPool = new DownloadPool(
            corePoolSize,
            maxPoolSize,
            keepAliveTime,
            TimeUnit.MILLISECONDS,
            workers,
            Executors.defaultThreadFactory(),
            handler);
}
 
開發者ID:Dpuntu,項目名稱:android-downloader,代碼行數:13,代碼來源:DownloadPool.java

示例7: TreadPool

import java.util.concurrent.ThreadPoolExecutor; //導入方法依賴的package包/類
private TreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime) {
    exec = new ThreadPoolExecutor(
            corePoolSize,// 核心線程數
            maximumPoolSize,// 最大線程數
            keepAliveTime,//閑置線程存活時間
            TimeUnit.SECONDS, // 時間單位
            new LinkedBlockingDeque<Runnable>(), // 線程隊列
            Executors.defaultThreadFactory(), // 線程工廠
            new ThreadPoolExecutor.AbortPolicy() // 隊列已滿,而且當前線程數已經超過最大線程數時的異常處理策略
    );
    scheduleExec = Executors.newScheduledThreadPool(corePoolSize);
}
 
開發者ID:penghongru,項目名稱:Coder,代碼行數:13,代碼來源:UThread.java

示例8: initial

import java.util.concurrent.ThreadPoolExecutor; //導入方法依賴的package包/類
public void initial() {
    RejectedExecutionHandler handler = null;
    if (discard) {
        handler = new ThreadPoolExecutor.DiscardPolicy();
    } else {
        handler = new ThreadPoolExecutor.AbortPolicy();
    }

    executor = new ThreadPoolExecutor(poolSize, poolSize, 60 * 1000L, TimeUnit.MILLISECONDS,
                                      new LinkedBlockingQueue<Runnable>(10 * 1000),
                                      new NamedThreadFactory("communication-async"), handler);
}
 
開發者ID:luoyaogui,項目名稱:otter-G,代碼行數:13,代碼來源:DefaultCommunicationClientImpl.java

示例9: init

import java.util.concurrent.ThreadPoolExecutor; //導入方法依賴的package包/類
@PostConstruct
public void init() {
    ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
        .setNameFormat("demo-pool-%d").build();

    //通用線程池
    executorService = new ThreadPoolExecutor(corePoolSize, maximumPoolSize,
        0L, TimeUnit.MILLISECONDS,
        new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
}
 
開發者ID:alibaba,項目名稱:bulbasaur,代碼行數:11,代碼來源:BulbasaurExecutorHelper.java

示例10: buildSimpleExecutorService

import java.util.concurrent.ThreadPoolExecutor; //導入方法依賴的package包/類
public static ExecutorService buildSimpleExecutorService() {
    ThreadFactory namedThreadFactory = Executors.defaultThreadFactory();
    return new ThreadPoolExecutor(1, 1,
            0L, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
}
 
開發者ID:shenhuanet,項目名稱:ZhidaoDaily-android,代碼行數:7,代碼來源:ThreadFactoryBuilder.java

示例11: setRejectedExecutionHandler

import java.util.concurrent.ThreadPoolExecutor; //導入方法依賴的package包/類
/**
 * Set the RejectedExecutionHandler to use for the ExecutorService.
 * Default is the ExecutorService's default abort policy.
 * @see java.util.concurrent.ThreadPoolExecutor.AbortPolicy
 */
public void setRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler) {
	this.rejectedExecutionHandler =
			(rejectedExecutionHandler != null ? rejectedExecutionHandler : new ThreadPoolExecutor.AbortPolicy());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:10,代碼來源:ExecutorConfigurationSupport.java


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