当前位置: 首页>>代码示例>>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;未经允许,请勿转载。