當前位置: 首頁>>代碼示例>>Java>>正文


Java ThreadPoolTaskExecutor.setKeepAliveSeconds方法代碼示例

本文整理匯總了Java中org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.setKeepAliveSeconds方法的典型用法代碼示例。如果您正苦於以下問題:Java ThreadPoolTaskExecutor.setKeepAliveSeconds方法的具體用法?Java ThreadPoolTaskExecutor.setKeepAliveSeconds怎麽用?Java ThreadPoolTaskExecutor.setKeepAliveSeconds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor的用法示例。


在下文中一共展示了ThreadPoolTaskExecutor.setKeepAliveSeconds方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: myTaskAsyncPool

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean
public ThreadPoolTaskExecutor myTaskAsyncPool() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(config.getCorePoolSize());
    executor.setMaxPoolSize(config.getMaxPoolSize());
    executor.setQueueCapacity(config.getQueueCapacity());
    executor.setKeepAliveSeconds(config.getKeepAliveSeconds());
    executor.setThreadNamePrefix("Async-");
    // rejection-policy:當pool已經達到max size的時候,如何處理新任務
    executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
    executor.initialize();
    return executor;
}
 
開發者ID:zhangtr,項目名稱:canal-mongo,代碼行數:14,代碼來源:TaskExecutePool.java

示例2: getAsyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Override
public Executor getAsyncExecutor() { // 2
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    //線程池維護線程的最少數量
    taskExecutor.setCorePoolSize(5);
    //線程池維護線程的最大數量
    taskExecutor.setMaxPoolSize(10);
    //線程池所使用的緩衝隊列
    taskExecutor.setQueueCapacity(1000);
    //線程池維護線程所允許的空閑時間
    taskExecutor.setKeepAliveSeconds(30000);
    taskExecutor.initialize();
    return taskExecutor;
}
 
開發者ID:Martion2017,項目名稱:ApplicationDetection,代碼行數:15,代碼來源:TaskExecutorConfig.java

示例3: taskExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean
public ThreadPoolTaskExecutor taskExecutor(){
    ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
    pool.setCorePoolSize(4);
    pool.setMaxPoolSize(50);
    pool.setQueueCapacity(200);
    pool.setKeepAliveSeconds(1);
    pool.setWaitForTasksToCompleteOnShutdown(false);
    return pool;
}
 
開發者ID:sweetca,項目名稱:logger,代碼行數:11,代碼來源:Application.java

示例4: clientInboundChannelExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean
public Executor clientInboundChannelExecutor() {
	ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
	executor.setThreadNamePrefix("wampClientInboundChannel-");
	executor.setCorePoolSize(Runtime.getRuntime().availableProcessors() * 2);
	executor.setMaxPoolSize(Integer.MAX_VALUE);
	executor.setKeepAliveSeconds(60);
	executor.setQueueCapacity(Integer.MAX_VALUE);
	executor.setAllowCoreThreadTimeOut(true);

	return executor;
}
 
開發者ID:ralscha,項目名稱:wamp2spring,代碼行數:13,代碼來源:WampConfiguration.java

示例5: clientOutboundChannelExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean
public Executor clientOutboundChannelExecutor() {
	ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
	executor.setThreadNamePrefix("wampClientOutboundChannel-");
	executor.setCorePoolSize(Runtime.getRuntime().availableProcessors() * 2);
	executor.setMaxPoolSize(Integer.MAX_VALUE);
	executor.setKeepAliveSeconds(60);
	executor.setQueueCapacity(Integer.MAX_VALUE);
	executor.setAllowCoreThreadTimeOut(true);

	return executor;
}
 
開發者ID:ralscha,項目名稱:wamp2spring,代碼行數:13,代碼來源:WampConfiguration.java

示例6: getAsyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Override
public Executor getAsyncExecutor() {
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(5);
    taskExecutor.setMaxPoolSize(500);
    taskExecutor.setQueueCapacity(600);
    taskExecutor.setKeepAliveSeconds(10);
    taskExecutor.initialize();
    return taskExecutor;
}
 
開發者ID:tong12580,項目名稱:OutsourcedProject,代碼行數:11,代碼來源:TaskExecutorConfig.java

示例7: threadPool

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean
public ThreadPoolTaskExecutor threadPool() {
    final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(Runtime.getRuntime().availableProcessors() * 4);
    executor.setMaxPoolSize(Runtime.getRuntime().availableProcessors() * 10);
    executor.setQueueCapacity(100);
    executor.setKeepAliveSeconds(300);
    executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    return executor;
}
 
開發者ID:csdbianhua,項目名稱:telemarket-skittle-alley,代碼行數:11,代碼來源:DataConfig.java

示例8: getProtocolleringAyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean
@Qualifier("protocolleringjob")
public Executor getProtocolleringAyncExecutor() {
    ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
    threadPoolTaskExecutor.setCorePoolSize(1);
    threadPoolTaskExecutor.setMaxPoolSize(1);
    threadPoolTaskExecutor.setQueueCapacity(0);
    threadPoolTaskExecutor.setKeepAliveSeconds(0);
    threadPoolTaskExecutor.initialize();
    return threadPoolTaskExecutor;
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:12,代碼來源:JobAsyncConfiguration.java

示例9: getSelectieJobAyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean
@Qualifier("selectiejob")
public Executor getSelectieJobAyncExecutor() {
    ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
    threadPoolTaskExecutor.setCorePoolSize(1);
    threadPoolTaskExecutor.setMaxPoolSize(1);
    threadPoolTaskExecutor.setQueueCapacity(0);
    threadPoolTaskExecutor.setKeepAliveSeconds(0);
    threadPoolTaskExecutor.initialize();
    return threadPoolTaskExecutor;
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:12,代碼來源:JobAsyncConfiguration.java

示例10: myTaskAsyncPool

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean
public Executor myTaskAsyncPool() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(config.getCorePoolSize());
    executor.setMaxPoolSize(config.getMaxPoolSize());
    executor.setQueueCapacity(config.getQueueCapacity());
    executor.setKeepAliveSeconds(config.getKeepAliveSeconds());
    executor.setThreadNamePrefix("MyExecutor-");

    // rejection-policy:當pool已經達到max size的時候,如何處理新任務
    // CALLER_RUNS:不在新線程中執行任務,而是由調用者所在的線程來執行
    executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    executor.initialize();
    return executor;
}
 
開發者ID:jeikerxiao,項目名稱:SpringBootStudy,代碼行數:16,代碼來源:TaskExecutePool.java

示例11: getWebServerTaskExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean(name = "webServerTaskExecutor")
public TaskExecutor getWebServerTaskExecutor(@Qualifier("pollingThreadFactory") final ThreadFactory threadFactory,
                                             @Value("${webserver.thread-task-executor.pool.size}") final int corePoolSize,
                                             @Value("${webserver.thread-task-executor.pool.max-size}") final int maxPoolSize,
                                             @Value("${webserver.thread-task-executor.pool.queue-capacity}") final int queueCapacity,
                                             @Value("${webserver.thread-task-executor.pool.keep-alive-sec}") final int keepAliveSeconds) {
    final ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
    threadPoolTaskExecutor.setCorePoolSize(corePoolSize);
    threadPoolTaskExecutor.setMaxPoolSize(maxPoolSize);
    threadPoolTaskExecutor.setQueueCapacity(queueCapacity);
    threadPoolTaskExecutor.setKeepAliveSeconds(keepAliveSeconds);
    threadPoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    threadPoolTaskExecutor.setThreadFactory(threadFactory);
    return threadPoolTaskExecutor;
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:16,代碼來源:AemServiceConfiguration.java

示例12: getJvmTaskExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean(name = "jvmTaskExecutor")
public TaskExecutor getJvmTaskExecutor(@Qualifier("pollingThreadFactory") final ThreadFactory threadFactory,
                                       @Value("${jvm.thread-task-executor.pool.size}") final int corePoolSize,
                                       @Value("${jvm.thread-task-executor.pool.max-size}") final int maxPoolSize,
                                       @Value("${jvm.thread-task-executor.pool.queue-capacity}") final int queueCapacity,
                                       @Value("${jvm.thread-task-executor.pool.keep-alive-sec}") final int keepAliveSeconds) {
    final ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
    threadPoolTaskExecutor.setCorePoolSize(corePoolSize);
    threadPoolTaskExecutor.setMaxPoolSize(maxPoolSize);
    threadPoolTaskExecutor.setQueueCapacity(queueCapacity);
    threadPoolTaskExecutor.setKeepAliveSeconds(keepAliveSeconds);
    threadPoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    threadPoolTaskExecutor.setThreadFactory(threadFactory);
    return threadPoolTaskExecutor;
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:16,代碼來源:AemServiceConfiguration.java

示例13: getAsyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean
public ThreadPoolTaskExecutor getAsyncExecutor() {
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(5);//線程池維護線程的最少數量
    taskExecutor.setMaxPoolSize(10);//線程池維護線程的最大數量
    taskExecutor.setQueueCapacity(25);//線程池所使用的緩衝隊列
    taskExecutor.setKeepAliveSeconds(10);
    taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    taskExecutor.initialize();
    return taskExecutor;
}
 
開發者ID:finefuture,項目名稱:data-migration,代碼行數:12,代碼來源:TaskExecutorConfiguration.java


注:本文中的org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.setKeepAliveSeconds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。