当前位置: 首页>>代码示例>>Java>>正文


Java RejectedExecutionHandler类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:19,代码来源:TransactionThreadPool.java

示例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();
    }
}
 
开发者ID:yu199195,项目名称:happylifeplat-tcc,代码行数:18,代码来源:TccTransactionThreadPool.java

示例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();
    }
}
 
开发者ID:yu199195,项目名称:myth,代码行数:18,代码来源:MythTransactionThreadPool.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:ScheduledExecutorFactoryBean.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:ThreadPoolExecutorFactoryBean.java

示例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);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:HadoopThreadPoolExecutor.java

示例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);
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:11,代码来源:LifecycleModule.java

示例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);
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:11,代码来源:CryptoModule.java

示例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);
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:11,代码来源:DatabaseExecutorModule.java

示例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);
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:9,代码来源:TimeLoggingExecutor.java

示例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);
}
 
开发者ID:Dpuntu,项目名称:android-downloader,代码行数:13,代码来源:DownloadPool.java

示例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;
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:14,代码来源:FairThreadPoolTaskExecutor.java

示例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);
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:8,代码来源:BaseExecutorGuiceModule.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:ThreadPoolTaskExecutor.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:ThreadPoolTaskScheduler.java


注:本文中的java.util.concurrent.RejectedExecutionHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。