Netty中传入NioEventLoopGroup的ThreadPoolExecutor的线程池大小
Thread pool size of ThreadPoolExecutor passed into NioEventLoopGroup in Netty
我想使用 Netty 中的 NioEventLoopGroup(int nThreads, Executor executor)
构造函数为 Netty worker 创建一个 EventLoopGroup
并使用 ScheduledExecutorService
定期检查一些条件并更改线程池大小ThreadPoolExecutor
实例(比如 myPool
)将第二个参数传递给构造函数。
当我对此进行测试时,我尝试定期增加 myPool
的线程池大小并注意到以下内容。
myPool.getPoolSize()
将始终小于或等于 nThread
的值。
但是 myPool.getCorePoolSize()
和 myPool.getMaximumPoolSize()
的输出显示 myPool
的 Core 和 Max pool size 确实在周期性增加,并且增加超过 nThread
.[=24= 的值]
nThread
是否限制了myPool
的最大线程数?
nThread
是NioEventLoopGroup
用来处理IO的线程数。所以是的,netty 永远不会使用比你在那里指定的更多的东西。
我想使用 Netty 中的 NioEventLoopGroup(int nThreads, Executor executor)
构造函数为 Netty worker 创建一个 EventLoopGroup
并使用 ScheduledExecutorService
定期检查一些条件并更改线程池大小ThreadPoolExecutor
实例(比如 myPool
)将第二个参数传递给构造函数。
当我对此进行测试时,我尝试定期增加 myPool
的线程池大小并注意到以下内容。
myPool.getPoolSize()
将始终小于或等于 nThread
的值。
但是 myPool.getCorePoolSize()
和 myPool.getMaximumPoolSize()
的输出显示 myPool
的 Core 和 Max pool size 确实在周期性增加,并且增加超过 nThread
.[=24= 的值]
nThread
是否限制了myPool
的最大线程数?
nThread
是NioEventLoopGroup
用来处理IO的线程数。所以是的,netty 永远不会使用比你在那里指定的更多的东西。