如果Netty中的操作需要较长的时间才能完成或正在阻塞,则建议在中执行该操作,
handler that uses a separateExecutorGroup以免主EventLoop线程被阻塞。
您可以在管道创建期间指定它。
引用从ChannelPipeline
javadoc使用执行程序组进行数据库操作的示例
static final EventExecutorGroup group = new DefaultEventExecutorGroup(16); ... ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast("deprer", new MyProtocolDeprer()); pipeline.addLast("enprer", new MyProtocolEnprer()); // Tell the pipeline to run MyBusinessLogicHandler's event handler methods // in a different thread than an I/O thread so that the I/O thread is not blocked by // a time-consuming task. // If your business logic is fully asynchronous or finished very quickly, you don't // need to specify a group. pipeline.addLast(group, "handler", new MyBusinessLogicHandler());


