Core pool size vs maximum pool size in ThreadPoolExecutor

后端 未结 10 1044
滥情空心
滥情空心 2020-11-29 16:08

What exactly is the difference between core pool size and maximum pool size when we talk in terms of ThreadPoolExecutor?
C

10条回答
  •  清酒与你
    2020-11-29 17:02

    You can find the definition of the terms corepoolsize and maxpoolsize in the javadoc. http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html

    The link above has the answer to your question. However, just to make it clear. The application will keep creating threads till it reaches the corePoolSize. I think the idea here is that these many threads should be sufficient to handle the inflow of tasks. If a new task comes after the corePoolSize threads are created the tasks will be queued. Once the queue is full the executor will start creating new threads. It is kind of balancing. What it essentially means is that the inflow of tasks is more than the processing capacity. So, Executor will start creating new threads again till it reaches Max number of threads. Again, a new threads will be created if and only if the queue is full.

提交回复
热议问题