本文整理匯總了Java中org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.initialize方法的典型用法代碼示例。如果您正苦於以下問題:Java ThreadPoolTaskExecutor.initialize方法的具體用法?Java ThreadPoolTaskExecutor.initialize怎麽用?Java ThreadPoolTaskExecutor.initialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
的用法示例。
在下文中一共展示了ThreadPoolTaskExecutor.initialize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: 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;
}
示例3: 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;
}
示例4: simpleApplicationEventMulticaster
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setThreadNamePrefix("asyncEventExecutor-");
taskExecutor.setCorePoolSize(4);
taskExecutor.initialize();
eventMulticaster.setTaskExecutor(taskExecutor);
return eventMulticaster;
}
示例5: getAsyncExecutor
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(2);
executor.setMaxPoolSize(100);
executor.setQueueCapacity(500);
executor.setThreadNamePrefix("AsyncProcess-");
executor.initialize();
return executor;
}
示例6: getAsyncExecutor
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(2);
executor.setMaxPoolSize(2);
executor.setQueueCapacity(500);
executor.setThreadNamePrefix("LotteryTask-");
executor.initialize();
return executor;
}
示例7: asyncConfig
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
/**
* @param threadNamePrefix -MailExecutor-
*/
public Executor asyncConfig(int corePoolSize, int maxPoolSize, int queueCapacity, String threadNamePrefix) {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(corePoolSize);
executor.setMaxPoolSize(maxPoolSize);
executor.setQueueCapacity(queueCapacity);
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.setThreadNamePrefix(threadNamePrefix);
executor.initialize();
return executor;
}
示例8: 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;
}
示例9: asyncExecutor
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean
public Executor asyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(4);
executor.setMaxPoolSize(4);
executor.setQueueCapacity(500);
executor.setThreadNamePrefix("spring-");
executor.initialize();
return executor;
}
示例10: asyncExecutor
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Bean
public Executor asyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setMaxPoolSize(5);
executor.setQueueCapacity(500);
executor.setThreadNamePrefix("AsyncJob-");
executor.initialize();
return executor;
}
示例11: getAsyncExecutor
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setThreadNamePrefix("AsyncExecutor-");
executor.initialize();
return executor;
}
示例12: threadPoolTaskExecutor
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Test
public void threadPoolTaskExecutor() {
ThreadPoolTaskExecutor exec = new ThreadPoolTaskExecutor();
exec.initialize();
ExecutorServiceMetrics.monitor(registry, exec.getThreadPoolExecutor(), "exec");
assertThreadPoolExecutorMetrics("exec");
}
示例13: monitorExecutorService
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Test
public void monitorExecutorService() throws InterruptedException {
CountDownLatch taskStart = new CountDownLatch(1);
CountDownLatch taskComplete = new CountDownLatch(1);
ThreadPoolTaskExecutor pool = ThreadPoolTaskExecutorMetrics.monitor(registry, "beep.pool", userTags);
pool.setMaxPoolSize(1);
pool.setAwaitTerminationSeconds(1);
pool.setWaitForTasksToCompleteOnShutdown(true);
pool.initialize();
pool.submit(() -> {
taskStart.countDown();
taskComplete.await(1, TimeUnit.SECONDS);
System.out.println("beep");
return 0;
});
pool.submit(() -> System.out.println("boop"));
taskStart.await(1, TimeUnit.SECONDS);
assertThat(registry.mustFind("beep.pool.queued").tags(userTags).gauge().value()).isEqualTo(1.0);
taskComplete.countDown();
pool.shutdown();
assertThat(registry.mustFind("beep.pool").tags(userTags).timer().count()).isEqualTo(2L);
assertThat(registry.mustFind("beep.pool.queued").tags(userTags).gauge().value()).isEqualTo(0.0);
}
示例14: 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;
}
示例15: getAsyncExecutor
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; //導入方法依賴的package包/類
@Override
public Executor getAsyncExecutor () {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize( Runtime.getRuntime().availableProcessors() );
executor.setMaxPoolSize( Runtime.getRuntime().availableProcessors() * 5 );
executor.setQueueCapacity( Runtime.getRuntime().availableProcessors() * 2 );
executor.setThreadNamePrefix( "aidijing-executor-" );
executor.initialize();
return executor;
}