當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。