I'm trying to create a ThreadPoolExecutor with a certain number of threads, but at the same time, i want to control the size of the pool queue. So I created the executor using the full constructor:
BlockingQueue<Runnable> pq =
new ArrayBlockingQueue<Runnable>(MAX_THREADPOOL_SIZE);
ThreadPoolExecutor threadPoolExecutor =
new ThreadPoolExecutor(threadSize, threadSize, THREAD_IDLE_WAIT,
TimeUnit.SECONDS, pq);
However, this gives me an IllegalArgumentException
. If I change the constructor to
new ThreadPoolExecutor(threadSize, **threadSize+1**, THREAD_IDLE_WAIT,
TimeUnit.SECONDS, pq);
it works. Why won't it work if I want the ideal and max amount of threads to be the same.