Core pool size vs maximum pool size in ThreadPoolExecutor

后端 未结 10 1041
滥情空心
滥情空心 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 16:50

    From this blog post:

    Take this example. Starting thread pool size is 1, core pool size is 5, max pool size is 10 and the queue is 100.

    As requests come in, threads will be created up to 5 and then tasks will be added to the queue until it reaches 100. When the queue is full new threads will be created up to maxPoolSize. Once all the threads are in use and the queue is full tasks will be rejected. As the queue reduces, so does the number of active threads.

提交回复
热议问题