我想寫一個udp服務器。我配置我的這樣引導:爲什麼netty只使用一個線程?
ChannelFactory factory = new NioDatagramChannelFactory(Executors.newCachedThreadPool());
ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(factory);
bootstrap.setPipelineFactory(new UDPServerPipelineFactory());
bootstrap.setOption("sendBufferSize", 1048576*2);
bootstrap.setOption("receiveBufferSize", 1048576*2);
bootstrap.setOption("tcpNoDelay", true);
bootstrap.setOption("receiveBufferSizePredictorFactory", new AdaptiveReceiveBufferSizePredictorFactory(1048576, 1048576, 2000000));
bootstrap.bind(new InetSocketAddress(11000));
Pipline這樣:
@Override
public ChannelPipeline getPipeline() throws Exception
{
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addFirst("execution-handler", new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(16, 2333444, 3444333)));
pipeline.addLast("decoder", new StringDecoder());
pipeline.addLast("counter", new UDPHandler());
return pipeline;
}
但我總是UDPHandler一個線程僅管理。我究竟做錯了什麼?
請問您可以添加'jstack'輸出嗎? – ericson 2013-02-28 14:39:34
感謝您的回覆。最後我發現有多個線程。我很困惑,因爲他們很少變化,對我來說就像一條線。我的錯。 – Moses 2013-02-28 14:50:51