Is netty's udp running in single-threaded mode?

I have configured the NioDatagramChannelFactory like below:

new NioDatagramChannelFactory(Executors.newFixedThreadPool(4), 4));

But, when I running the code as a server, and lunch more than 20 clients to send udp packages continuously to it, the server still use only one worker thread.

Why?

有帮助吗?

解决方案

Normally it should use 4 worker threads here. So how are you seeing that it only use one thread ? Did you check with jstack to see how many worker threads are running ?

You should also use

new NioDatagramChannelFactory(Executors.newCachedThreadPool(), 4));

This should take care of having at max. 4 worker threads.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top