这个是源码中默认的线程数。
因为自己的cpu是8核心的,所以是cpu数量的2倍,这个是默认值
EventLoopGroup bossGroup = new NioEventLoopGroup(2);
EventLoopGroup workGroup = new NioEventLoopGroup(2);
如果我们这样设置
客户端有4个请求连接会是什么样
nioEventLoopGroup-3-1
ctx = ChannelHandlerContext(Nhandler#0, [id: 0xaee4fec7, L:/127.0.0.1:12312 - R:/127.0.0.1:55988])
client:大哥,大哥,大哥
address:/127.0.0.1:55988
nioEventLoopGroup-3-2
ctx = ChannelHandlerContext(Nhandler#0, [id: 0x231c2480, L:/127.0.0.1:12312 - R:/127.0.0.1:56039])
client:大哥,大哥,大哥
address:/127.0.0.1:56039
nioEventLoopGroup-3-1
ctx = ChannelHandlerContext(Nhandler#0, [id: 0xdc20672e, L:/127.0.0.1:12312 - R:/127.0.0.1:56078])
client:大哥,大哥,大哥
address:/127.0.0.1:56078
nioEventLoopGroup-3-2
ctx = ChannelHandlerContext(Nhandler#0, [id: 0x4e6be1b1, L:/127.0.0.1:12312 - R:/127.0.0.1:56116])
client:大哥,大哥,大哥
address:/127.0.0.1:56116
其实就是轮询。
System.out.println("ctx = " + ctx);
System.out.println("ctx.channel() = " + ctx.channel());
System.out.println("ctx.pipeline() = " + ctx.pipeline());
ctx就是有web的