I\'m trying to understand ThreadPoolExecutor class. I have read this answer and the Javadoc. But my experimentation doesn\'t match with that description:
I initializ
From the API for ThreadPoolExecutor:
If there are more than corePoolSize but less than maximumPoolSize threads running, a new thread will be created only if the queue is full.
Your queue never fills since it has a capacity of 1000
. If you change the capacity to 1
, you will see Thread
s being created.
The Executors class uses a SynchronousQueue for its newCachedThreadPool
methods, so you might want to consider using it as well.