本文整理匯總了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;
}