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