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


Java ThreadPoolTaskExecutor類代碼示例

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


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

示例1: getAsyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
@Override
@Bean
public Executor getAsyncExecutor() {
    log.debug("Creating Async Task Executor");
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(5);
    executor.setMaxPoolSize(50);

    executor.setWaitForTasksToCompleteOnShutdown(true);

    executor.setQueueCapacity(10000);
    executor.setThreadNamePrefix("cloudunit-Executor-");
    executor.initialize();
    return executor;
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:16,代碼來源:AsyncConfiguration.java

示例2: executor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
@Test
public void executor() throws InterruptedException {
    CountDownLatch lock = new CountDownLatch(1);
    ThreadPoolTaskExecutor pool = ThreadPoolTaskExecutorMetrics.monitor(registry, "exec", userTags);
    pool.setAwaitTerminationSeconds(1);
    pool.initialize();
    pool.execute(() -> {
        System.out.println("hello");
        lock.countDown();
    });
    lock.await();
    pool.shutdown();

    assertThat(registry.mustFind("exec").tags(userTags).timer().count()).isEqualTo(1L);
    registry.mustFind("exec.completed").tags(userTags).functionCounter();
    registry.mustFind("exec.queued").tags(userTags).gauge();
    registry.mustFind("exec.active").tags(userTags).gauge();
    registry.mustFind("exec.pool").tags(userTags).gauge();
}
 
開發者ID:micrometer-metrics,項目名稱:micrometer,代碼行數:20,代碼來源:ThreadPoolTaskExecutorMetricsTest.java

示例3: createDefaultTaskExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
private TaskExecutor createDefaultTaskExecutor() {
	// create thread-pool for starting contexts
	ThreadGroup threadGroup =
			new ThreadGroup("eclipse-gemini-blueprint-extender[" + ObjectUtils.getIdentityHexString(this) + "]-threads");
	threadGroup.setDaemon(false);

	ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
	taskExecutor.setMaxPoolSize(Runtime.getRuntime().availableProcessors());
	taskExecutor.setThreadGroup(threadGroup);
	taskExecutor.setThreadNamePrefix("EclipseGeminiBlueprintExtenderThread-");
	taskExecutor.initialize();

	isTaskExecutorManagedInternally = true;

	return taskExecutor;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:17,代碼來源:ExtenderConfiguration.java

示例4: stopLoad

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
@Override
public void stopLoad(final Node root) {
    ThreadPoolTaskExecutor executor = nodeThreadPool.getIfPresent(root.getPath());
    if (executor == null || executor.getActiveCount() == 0) {
        return;
    }

    if (!isYmlLoading(root)) {
        return;
    }

    executor.shutdown();
    nodeThreadPool.invalidate(root.getPath());

    LOGGER.trace("Yml loading task been stopped for path %s", root.getPath());
    nodeService.updateYmlState(root, YmlStatusValue.NOT_FOUND, null);
}
 
開發者ID:FlowCI,項目名稱:flow-platform,代碼行數:18,代碼來源:YmlServiceImpl.java

示例5: getAsyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
@Bean(name = SKIPPER_EXECUTOR)
@Override
public Executor getAsyncExecutor() {
	ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
	threadPoolTaskExecutor.setCorePoolSize(5);
	threadPoolTaskExecutor.setMaxPoolSize(10);
	threadPoolTaskExecutor.setThreadNamePrefix("StateUpdate-");
	return threadPoolTaskExecutor;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:10,代碼來源:SkipperServerConfiguration.java

示例6: 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

示例7: getAsyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
@Override
@Bean(name = "taskExecutor")
public Executor getAsyncExecutor() {
    log.debug("Creating Async Task Executor");
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(jHipsterProperties.getAsync().getCorePoolSize());
    executor.setMaxPoolSize(jHipsterProperties.getAsync().getMaxPoolSize());
    executor.setQueueCapacity(jHipsterProperties.getAsync().getQueueCapacity());
    executor.setThreadNamePrefix("blog-Executor-");
    return new ExceptionHandlingAsyncTaskExecutor(executor);
}
 
開發者ID:oktadeveloper,項目名稱:jhipster-microservices-example,代碼行數:12,代碼來源:AsyncConfiguration.java

示例8: getAsyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
@Override
@Bean(name = "taskExecutor")
public Executor getAsyncExecutor() {
    log.debug("Creating Async Task Executor");
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(jHipsterProperties.getAsync().getCorePoolSize());
    executor.setMaxPoolSize(jHipsterProperties.getAsync().getMaxPoolSize());
    executor.setQueueCapacity(jHipsterProperties.getAsync().getQueueCapacity());
    executor.setThreadNamePrefix("j-hipster-registry-Executor-");
    return new ExceptionHandlingAsyncTaskExecutor(executor);
}
 
開發者ID:oktadeveloper,項目名稱:jhipster-microservices-example,代碼行數:12,代碼來源:AsyncConfiguration.java

示例9: getAsyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
@Override
@Bean(name = "taskExecutor")
public Executor getAsyncExecutor() {
    log.debug("Creating Async Task Executor");
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(jHipsterProperties.getAsync().getCorePoolSize());
    executor.setMaxPoolSize(jHipsterProperties.getAsync().getMaxPoolSize());
    executor.setQueueCapacity(jHipsterProperties.getAsync().getQueueCapacity());
    executor.setThreadNamePrefix("store-Executor-");
    return new ExceptionHandlingAsyncTaskExecutor(executor);
}
 
開發者ID:oktadeveloper,項目名稱:jhipster-microservices-example,代碼行數:12,代碼來源:AsyncConfiguration.java

示例10: 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

示例11: getAsyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
@Override
@Bean(name = "taskExecutor")
public Executor getAsyncExecutor() {
    log.debug("Creating Async Task Executor");
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(jHipsterProperties.getAsync().getCorePoolSize());
    executor.setMaxPoolSize(jHipsterProperties.getAsync().getMaxPoolSize());
    executor.setQueueCapacity(jHipsterProperties.getAsync().getQueueCapacity());
    executor.setThreadNamePrefix("labrat-Executor-");
    return new ExceptionHandlingAsyncTaskExecutor(executor);
}
 
開發者ID:Microsoft,項目名稱:MTC_Labrat,代碼行數:12,代碼來源:AsyncConfiguration.java

示例12: initExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
private static ThreadPoolTaskExecutor initExecutor() {
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(5);
    taskExecutor.setMaxPoolSize(5);
    taskExecutor.setQueueCapacity(100);
    taskExecutor.setThreadNamePrefix("plugin-");
    taskExecutor.setDaemon(true);
    return taskExecutor;
}
 
開發者ID:FlowCI,項目名稱:flow-platform,代碼行數:10,代碼來源:PluginConfig.java

示例13: mySimpleAsync

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
@Bean
public Executor mySimpleAsync() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(corePoolSize);
    executor.setMaxPoolSize(maxPoolSize);
    executor.setQueueCapacity(queueCapacity);
    executor.setThreadNamePrefix("MySimpleExecutor-");
    executor.initialize();
    return executor;
}
 
開發者ID:fier-liu,項目名稱:FCat,代碼行數:11,代碼來源:ExecutorConfig.java

示例14: asyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
@Bean
public Executor asyncExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(2);
    executor.setMaxPoolSize(4);
    executor.setQueueCapacity(100);
    executor.setThreadNamePrefix("MyExecutor-");
    executor.initialize();
    return executor;
}
 
開發者ID:hantsy,項目名稱:spring-reactive-sample,代碼行數:11,代碼來源:Application.java

示例15: getAsyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入依賴的package包/類
@Override
@Bean(name = "taskExecutor")
public Executor getAsyncExecutor() {
    log.debug("Creating Async Task Executor");
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(jHipsterProperties.getAsync().getCorePoolSize());
    executor.setMaxPoolSize(jHipsterProperties.getAsync().getMaxPoolSize());
    executor.setQueueCapacity(jHipsterProperties.getAsync().getQueueCapacity());
    executor.setThreadNamePrefix("buen-ojo-Executor-");
    return new ExceptionHandlingAsyncTaskExecutor(executor);
}
 
開發者ID:GastonMauroDiaz,項目名稱:buenojo,代碼行數:12,代碼來源:AsyncConfiguration.java


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