不错,遇到问题反复看了几遍总有启发,还说收藏记录一下。html
http://www.infoq.com/cn/nettyjava
Netty案例集锦之多线程篇(续)做者 李林锋 发布于 2015年11月25日 9编程
Netty案例集锦之多线程篇做者 李林锋 发布于 2015年9月3日 14api
Netty系列之Netty编解码框架分析做者 李林锋 发布于 2015年4月29日 22安全
Netty版本升级血泪史之线程篇做者 李林锋 发布于 2015年2月7日 18网络
Netty系列之Netty百万级推送服务设计要点做者 李林锋 发布于 2015年1月4日 31多线程
Netty系列之Netty并发编程分析做者 李林锋 发布于 2014年10月24日 17并发
Netty系列之Netty 服务端建立做者 李林锋 发布于 2014年9月11日 20框架
Netty系列之Netty安全性做者 李林锋 发布于 2014年8月8日 11async
Netty系列之Netty线程模型做者 李林锋 发布于 2014年7月11日 25
Netty系列之Netty可靠性分析做者 李林锋 发布于 2014年6月19日 29
Netty系列之Netty高性能之道做者 李林锋 发布于 2014年5月30日 48
http://www.cnblogs.com/Security-Darren/p/4700387.html
http://xw-z1985.iteye.com/category/260393
要关注3个地方的线程处理:
a.BOSS线程:处理链接创建(服务端才有)
b.worker线程:处理IO、解码(read等)
c.一个channel发了多个消息的,消息并发处理(初步看是用本身实现的业务线程池)
知乎的讨论:
https://www.zhihu.com/question/35487154(ExecutionHandler是netty3的东西,4已经去掉)
EventLoop:其本质是一个用来处理IO事件的线程,EventLoopGroup 其本质是一个线程池。一个EventLoop会对应着一个线程,一个EventLoop能够和多个Channel绑定,处理多个Channel的IO事件;可是一个Channel在整个生命周期内只会被一个EventLoop处理
http://blog.csdn.net/suifeng3051/article/details/28861883
官方文档:(解决了IO worker线程不堵塞的问题,但看源码一个handler只绑定一个线程,并不能解决handler处理的效率问题,例如一个链接发的消息不少,可是handler消息处理并不会并发执行)
https://netty.io/4.1/api/io/netty/channel/ChannelPipeline.html
static final EventExecutorGroup group = new DefaultEventExecutorGroup}(16); ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast("decoder", new MyProtocolDecoder()); pipeline.addLast("encoder", new MyProtocolEncoder()); // 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());
AbstractChannelHandlerContext(DefaultChannelPipeline pipeline, EventExecutorGroup group, String name, boolean inbound, boolean outbound) { if (name == null) { throw new NullPointerException("name"); } channel = pipeline.channel; this.pipeline = pipeline; this.name = name; if (group != null) { // Pin one of the child executors once and remember it so that the same child executor // is used to fire events for the same channel. EventExecutor childExecutor = pipeline.childExecutors.get(group); if (childExecutor == null) { childExecutor = group.next(); pipeline.childExecutors.put(group, childExecutor); } executor = childExecutor; } else { executor = null; } this.inbound = inbound; this.outbound = outbound; }
最后固然不能忘了官方文档:
http://netty.io/wiki/user-guide-for-4.x.html
http://netty.io/wiki/related-articles.html