2
如果我代碼下面的代碼段:netty可以將多個IO線程分配給同一個通道嗎?
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具有輸入
- 網狀分配線程T1線程之後到信道C1
- T1已讀取來自通道C1的所有輸入,並且在它仍在處理輸入時,更多輸入到達通道C1
我的問題是:netty會爲C1通道分配一個新線程(假設線程池中有空閒線程)?提前
謝謝,諾曼。所以,一個通道在任何時候都不能有多個IO線程分配給它,對吧? – user1902850
正是..這就是當前線程模型的工作原理 –
我是否正確地說這是由select和epoll引起的限制引起的?在這裏討論https://idea.popcount.org/2017-02-20-epoll-is-fundamentally-broken-12/ – robert