本文整理汇总了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;
}
示例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());
}
示例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());
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}