AE
Size: a a a
AE
Ar
V@
Ar
TZ
@Configuration
@EnableAsync
public class AsyncConfig {
private static final String THREAD_POOL_TASK_EXECUTOR = "threadPoolTaskExecutor";
@Bean(THREAD_POOL_TASK_EXECUTOR)
public TaskExecutor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(20);
executor.setMaxPoolSize(1000);
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.setThreadNamePrefix("Async-");
return executor;
}
}
TZ
TZ
spring
task:
execution:
pool:
core-size: 20
max-size: 1000
shutdown:
await-termination: false
scheduling:
thread-name-prefix: Async-
TZ
TZ
РН
TZ
TZ
@Configuration
@EnableAsync
@Getter
@Setter
public class AsyncConfig {
private static final String THREAD_POOL_TASK_EXECUTOR = "threadPoolTaskExecutor";
@Value("${spring.task.execution.pool.core-size}")
private int corePoolSize;
@Value("${spring.task.execution.pool.max-size}")
private int maxPoolSize;
@Value("${spring.task.execution.shutdown.await-termination}")
private boolean waitForTasksToCompleteOnShutdown;
@Value("${spring.task.scheduling.thread-name-prefix}")
private String threadNamePrefix;
@Bean(THREAD_POOL_TASK_EXECUTOR)
public TaskExecutor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(corePoolSize);
executor.setMaxPoolSize(maxPoolSize);
executor.setWaitForTasksToCompleteOnShutdown(waitForTasksToCompleteOnShutdown);
executor.setThreadNamePrefix(threadNamePrefix);
return executor;
}
}
TZ
РН
TZ
TZ
AE
@ConfigurationProperties
TZ
Ar
AE