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


Java ThreadPoolTaskExecutor.initialize方法代碼示例

本文整理匯總了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();
}
 
開發者ID:micrometer-metrics,項目名稱:micrometer,代碼行數:20,代碼來源:ThreadPoolTaskExecutorMetricsTest.java

示例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;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:17,代碼來源:ExtenderConfiguration.java

示例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;
}
 
開發者ID:finefuture,項目名稱:data-migration,代碼行數:12,代碼來源:TaskExecutorConfiguration.java

示例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;
}
 
開發者ID:jeperon,項目名稱:freqtrade-java,代碼行數:13,代碼來源:FreqTradeConfiguration.java

示例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;
}
 
開發者ID:TulevaEE,項目名稱:onboarding-service,代碼行數:11,代碼來源:AsyncConfiguration.java

示例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;
}
 
開發者ID:kyawswa,項目名稱:myanmarlottery,代碼行數:11,代碼來源:AppConfig.java

示例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;
}
 
開發者ID:CharleyXu,項目名稱:tulingchat,代碼行數:14,代碼來源:ExecutorConfig.java

示例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;
}
 
開發者ID:Martion2017,項目名稱:ApplicationDetection,代碼行數:15,代碼來源:TaskExecutorConfig.java

示例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;
}
 
開發者ID:peterjurkovic,項目名稱:travel-agency,代碼行數:11,代碼來源:SchedulerConfiguration.java

示例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;
}
 
開發者ID:oojorgeoo89,項目名稱:QuizZz,代碼行數:11,代碼來源:AsyncConfig.java

示例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;
}
 
開發者ID:ruslanys,項目名稱:vkmusic,代碼行數:9,代碼來源:ExecutorsConfig.java

示例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");
}
 
開發者ID:micrometer-metrics,項目名稱:micrometer,代碼行數:9,代碼來源:ExecutorServiceMetricsTest.java

示例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);
}
 
開發者ID:micrometer-metrics,項目名稱:micrometer,代碼行數:28,代碼來源:ThreadPoolTaskExecutorMetricsTest.java

示例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;
}
 
開發者ID:tong12580,項目名稱:OutsourcedProject,代碼行數:11,代碼來源:TaskExecutorConfig.java

示例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;
}
 
開發者ID:yujunhao8831,項目名稱:spring-boot-start-current,代碼行數:11,代碼來源:ThreadPoolConfig.java


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