netty能否将多个IO线程分配给同一通道?
如果我要对以下代码段进行编码:netty能否将多个IO线程分配给同一通道?,netty,Netty,如果我要对以下代码段进行编码: class SimpleHandler extends SimpleChannelUpstreamHandler { ... public static void main( String[] args ) throws Exception { ServerBootstrap b = new ServerBootstrap( new NioServerSocketChannelFactory( E
class SimpleHandler extends SimpleChannelUpstreamHandler {
...
public static void main( String[] args ) throws Exception {
ServerBootstrap b = new ServerBootstrap(
new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool(),
10 ));
b.setPipelineFactory( new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline( new SimpleHandler() );
}
});
b.bind( new InetSocketAddress( p ));
}
并假设以下情况:
- 通道C1有输入
- netty将线程T1分配给通道C1
- 线程T1从通道C1读取所有输入后,当它仍在处理输入时,更多的输入到达通道C1
提前感谢一旦将线程/选择器分配给频道,它将在其整个生命周期中使用相同的线程/选择器。所以它将一直由相同的人供应。谢谢,诺曼。因此,一个通道在任何时候都不能有多个IO线程分配给它,对吗?我说这是由于select和epoll产生的限制造成的,对吗?这里讨论