gpt4 book ai didi

java - ThreadPoolExecutor 中的核心池大小与最大池大小

转载 作者:行者123 更新时间:2023-12-03 05:17:59 26 4
gpt4 key购买 nike

当我们谈论ThreadPoolExecutor时,核心池大小最大池大小之间到底有什么区别?
可以用例子来解释吗?

最佳答案

来自this blog post :

Take this example. Starting thread pool size is 1, core pool size is5, 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 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.

关于java - ThreadPoolExecutor 中的核心池大小与最大池大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17659510/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com