공부를 열심히 해도 잊어지는 건 어쩔 수 없나 보다. 그래서 기록으로 남겨둔다.
1. ThreadPoolTaskExecutor 설정
- corePoolSize 까지 Thread 만들기
- corePoolSize 가득 차면 queueCapacity 까지 큐잉
- queueCapacity 넘을 때 maxPoolSize까지 Thread 증가
- maxPoolSize 넘을 때 거부
@Bean
ThreadPoolTaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(4);
taskExecutor.setQueueCapacity(4);
taskExecutor.setMaxPoolSize(40);
return taskExecutor;
}
그리고 ThreadPoolTaskExecutor가 위양하고 있는 java.util.concurrent.ThreadPoolExecutor 를 만들 때는 다음과 같은 사용법을 사용하는 경우가 많은데
ExecutorService executorService = Executors.newFixedThreadPool(40);위의 방법은 아래와 같은 의미이다.
@Bean
ThreadPoolTaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(40);
taskExecutor.setMaxPoolSize(40);
return taskExecutor;
}








