Primary and maximum pool sizes
ThreadPoolExecutor automatically adjusts the pool size to the limits set by corePoolSize and maximumPoolSize.
When a new task is dispatched in the execute(java.lang.Runnable) method execute(java.lang.Runnable) and fewer corePoolSize threads are executed, a new thread is created to process the request, even if other worker threads are idle. If there is more than corePoolSize, but less than maximumPoolSize threads are running, a new thread will only be created if the queue is full. By setting corePoolSize and maximumPoolSize the same, you create a fixed-size thread pool.
By setting maxPoolSize to a substantially unlimited value, such as Integer.MAX_VALUE , you allow the pool to accommodate an arbitrary number of simultaneous tasks. As a rule, the kernel and maximum pool sizes are set only during construction, but they can also be dynamically changed using setCorePoolSize(int) and setMaximumPoolSize(int) . link
Adelin Jan 29 '14 at 22:16 2014-01-29 22:16
source share