本文整理汇总了Java中java.util.concurrent.RejectedExecutionHandler类的典型用法代码示例。如果您正苦于以下问题:Java RejectedExecutionHandler类的具体用法?Java RejectedExecutionHandler怎么用?Java RejectedExecutionHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RejectedExecutionHandler类属于java.util.concurrent包,在下文中一共展示了RejectedExecutionHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPolicy
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
private RejectedExecutionHandler createPolicy() {
RejectedPolicyTypeEnum rejectedPolicyType = RejectedPolicyTypeEnum.fromString(txConfig.getRejectPolicy());
switch (rejectedPolicyType) {
case BLOCKING_POLICY:
return new BlockingPolicy();
case CALLER_RUNS_POLICY:
return new CallerRunsPolicy();
case ABORT_POLICY:
return new AbortPolicy();
case REJECTED_POLICY:
return new RejectedPolicy();
case DISCARDED_POLICY:
return new DiscardedPolicy();
default:
return new RejectedPolicy();
}
}
示例2: createPolicy
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
private RejectedExecutionHandler createPolicy() {
RejectedPolicyTypeEnum rejectedPolicyType = RejectedPolicyTypeEnum.fromString(tccConfig.getRejectPolicy());
switch (rejectedPolicyType) {
case BLOCKING_POLICY:
return new BlockingPolicy();
case CALLER_RUNS_POLICY:
return new CallerRunsPolicy();
case ABORT_POLICY:
return new AbortPolicy();
case REJECTED_POLICY:
return new RejectedPolicy();
case DISCARDED_POLICY:
return new DiscardedPolicy();
default:
return new AbortPolicy();
}
}
示例3: createPolicy
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
private RejectedExecutionHandler createPolicy() {
RejectedPolicyTypeEnum rejectedPolicyType = RejectedPolicyTypeEnum.fromString(mythConfig.getRejectPolicy());
switch (rejectedPolicyType) {
case BLOCKING_POLICY:
return new BlockingPolicy();
case CALLER_RUNS_POLICY:
return new CallerRunsPolicy();
case ABORT_POLICY:
return new AbortPolicy();
case REJECTED_POLICY:
return new RejectedPolicy();
case DISCARDED_POLICY:
return new DiscardedPolicy();
default:
return new DiscardedPolicy();
}
}
示例4: initializeExecutor
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
@Override
protected ExecutorService initializeExecutor(
ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
ScheduledExecutorService executor =
createExecutor(this.poolSize, threadFactory, rejectedExecutionHandler);
if (executor instanceof ScheduledThreadPoolExecutor && this.removeOnCancelPolicy != null) {
((ScheduledThreadPoolExecutor) executor).setRemoveOnCancelPolicy(this.removeOnCancelPolicy);
}
// Register specified ScheduledExecutorTasks, if necessary.
if (!ObjectUtils.isEmpty(this.scheduledExecutorTasks)) {
registerTasks(this.scheduledExecutorTasks, executor);
}
// Wrap executor with an unconfigurable decorator.
this.exposedExecutor = (this.exposeUnconfigurableExecutor ?
Executors.unconfigurableScheduledExecutorService(executor) : executor);
return executor;
}
示例5: initializeExecutor
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
@Override
protected ExecutorService initializeExecutor(
ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
BlockingQueue<Runnable> queue = createQueue(this.queueCapacity);
ThreadPoolExecutor executor = createExecutor(this.corePoolSize, this.maxPoolSize,
this.keepAliveSeconds, queue, threadFactory, rejectedExecutionHandler);
if (this.allowCoreThreadTimeOut) {
executor.allowCoreThreadTimeOut(true);
}
// Wrap executor with an unconfigurable decorator.
this.exposedExecutor = (this.exposeUnconfigurableExecutor ?
Executors.unconfigurableExecutorService(executor) : executor);
return executor;
}
示例6: HadoopThreadPoolExecutor
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
public HadoopThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
RejectedExecutionHandler handler) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue,
handler);
}
示例7: LifecycleModule
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
public LifecycleModule() {
// The thread pool is unbounded, so use direct handoff
BlockingQueue<Runnable> queue = new SynchronousQueue<Runnable>();
// Discard tasks that are submitted during shutdown
RejectedExecutionHandler policy =
new ThreadPoolExecutor.DiscardPolicy();
// Create threads as required and keep them in the pool for 60 seconds
ioExecutor = new ThreadPoolExecutor(0, Integer.MAX_VALUE,
60, SECONDS, queue, policy);
}
示例8: CryptoModule
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
public CryptoModule() {
// Use an unbounded queue
BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
// Discard tasks that are submitted during shutdown
RejectedExecutionHandler policy =
new ThreadPoolExecutor.DiscardPolicy();
// Create a limited # of threads and keep them in the pool for 60 secs
cryptoExecutor = new TimeLoggingExecutor("CryptoExecutor", 0,
MAX_EXECUTOR_THREADS, 60, SECONDS, queue, policy);
}
示例9: DatabaseExecutorModule
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
public DatabaseExecutorModule() {
// Use an unbounded queue
BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
// Discard tasks that are submitted during shutdown
RejectedExecutionHandler policy =
new ThreadPoolExecutor.DiscardPolicy();
// Use a single thread and keep it in the pool for 60 secs
databaseExecutor = new TimeLoggingExecutor("DatabaseExecutor", 0, 1,
60, SECONDS, queue, policy);
}
示例10: TimeLoggingExecutor
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
public TimeLoggingExecutor(String tag, int corePoolSize, int maxPoolSize,
long keepAliveTime, TimeUnit unit,
BlockingQueue<Runnable> workQueue,
RejectedExecutionHandler handler) {
super(corePoolSize, maxPoolSize, keepAliveTime, unit, workQueue,
handler);
log = Logger.getLogger(tag);
}
示例11: createPool
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的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);
}
示例12: initializeExecutor
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
@Override
protected ExecutorService initializeExecutor (ThreadFactory threadFactory,
RejectedExecutionHandler rejectedExecutionHandler)
{
FairQueue<Runnable> queue = new FairQueue<Runnable> ();
ThreadPoolExecutor executor =
new ThreadPoolExecutor (this.corePoolSize, this.corePoolSize,
keepAliveSeconds, TimeUnit.SECONDS, queue, threadFactory,
rejectedExecutionHandler);
this.threadPoolExecutor = executor;
return executor;
}
示例13: createThreadPool
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
protected ThreadPoolExecutor createThreadPool(ThreadGroup parentGroup, String name, int minThreadCound,
int maxThreadCount, int queueSize, RejectedExecutionHandler rejectPolicy){
ThreadFactory threadFactory = new NamedThreadFactory(parentGroup, name, true);
BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>(queueSize);
return new ThreadPoolExecutor(minThreadCound, maxThreadCount, 1, TimeUnit.MINUTES, queue, threadFactory,
rejectPolicy);
}
示例14: initializeExecutor
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
@Override
protected ExecutorService initializeExecutor(
ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
BlockingQueue<Runnable> queue = createQueue(this.queueCapacity);
ThreadPoolExecutor executor = new ThreadPoolExecutor(
this.corePoolSize, this.maxPoolSize, this.keepAliveSeconds, TimeUnit.SECONDS,
queue, threadFactory, rejectedExecutionHandler);
if (this.allowCoreThreadTimeOut) {
executor.allowCoreThreadTimeOut(true);
}
this.threadPoolExecutor = executor;
return executor;
}
示例15: initializeExecutor
import java.util.concurrent.RejectedExecutionHandler; //导入依赖的package包/类
@Override
protected ExecutorService initializeExecutor(
ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
this.scheduledExecutor = createExecutor(this.poolSize, threadFactory, rejectedExecutionHandler);
if (this.scheduledExecutor instanceof ScheduledThreadPoolExecutor && this.removeOnCancelPolicy != null) {
((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(this.removeOnCancelPolicy);
}
return this.scheduledExecutor;
}