쓰레드 풀을 이용하여 어플리케이션이 더 효율적으로 쓰레드를 관리할 수 있다. Executors
는 그러한 쓰레드 풀(ThreadPoolExecutor
) 을 만드는 객체이다.
*newFixedThreadPool
*
corePoolSize
: 입력된 쓰레드 개수
maximumPoolSize
: 입력된 쓰레드 개수
keepAliveTime
: 0초
하나의 Queue 를 생성한다. (LinkedBlockingQueue
)
고정된 개수의 쓰레드를 가지는 쓰레들 풀을 생성한다.
쓰레드 개수를 넘는 task 가 들어올 경우 사용할 수 있는 쓰레드가 생길때까지 대기한다.
예외가 발생하여 종료된 쓰레드가 생기면 새로운 쓰레드로 대체한다.
newCachedThreadPool
corePoolSize
: 0maximumPoolSize
: Integer.*MAX_VALUE(*0x7fffffff)keepAliveTime
: 60초SynchronousQueue
)