本文介绍了核心池大小与ThreadPoolExecutor中的最大池大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们用ThreadPoolExecutor进行交谈时,核心池大小最大池大小之间到底有什么区别?
可以借助示例进行解释吗?

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?

推荐答案

来自此博客文章:

随着请求的到来,最多创建5个线程,然后将任务添加到队列,直到达到100.当队列已满时,将有新线程最多创建到maxPoolSize.一旦所有线程都被使用,并且队列已满,任务将被拒绝.随着队列的减少,也是如此活动线程数.

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

这篇关于核心池大小与ThreadPoolExecutor中的最大池大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:21
查看更多