Core pool size vs maximum pool size in ThreadPoolExecutor Ask Question

Core pool size vs maximum pool size in ThreadPoolExecutor Ask Question

What exactly is the difference between core pool size and maximum pool size when we talk in terms of ThreadPoolExecutor?
Can it be explained with the help of an example?

ベストアンサー1

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.

おすすめ記事