我对你的问题有点困惑,所以我希望这能回答这个问题。。。。所使用的线程
EventLoopGroup
是“IO线程”,传入的数字是要使用的“IO线程”数。每个线程将处理0-n个通道。要增加IO线程的数量,可以指定一个不同的数字,然后在此处指定“16”。
每个通道仅使用一个“IO线程”。如果要确保
ChannelHandler
将从通常创建的IO线程中卸载
DefaultEventExecutorGroup
并在添加
ChannelHandler
. 这个
EventExecutorGroup
应在不同的
Channel
实例以充分利用线程tho。
类似这样:
NioEventLoopGroup workerGroup = new NioEventLoopGroup(16)
EventExecutorGroup executorGroup = new DefaultEventExecutorGroup(numberOfThreads);
new ServerBootstrap()
.childHandler(
new ChannelInitializer<Channel> {
override def initChannel(ch: Channel) = ch.pipeline()
.addLast(new ChannelDuplexHandler)
.addLast(executorGroup, new HttpRequestDecoder())
}