EventLoop相當于一個Thread線程,而EventLoopGroup則是管理這些EventLoop的Thread線程池
EventLoop接口
package io.netty.channel;
public interface EventLoop extends EventExecutor, EventLoopGroup {
@Override
EventLoopGroup parent();
}

EventLoop接口UML圖
parent()方法
返回管理這個EventLoop的EventLoopGroup。
EventLoopGroup接口
package io.netty.channel;
public interface EventLoopGroup extends EventExecutorGroup {
@Override
EventLoop next();
ChannelFuture register(Channel channel);
ChannelFuture register(Channel channel, ChannelFuture future);
}

EventLoopGroup接口UML圖
next()
返回下一個EventLoop
register(Channel channel)
指定一個EventLoopGroup來注冊某個Channel。
備注:因為筆者開始寫Netty源碼分析的時候,Netty 4.0還是處于Alpha階段,之后的API可能還會有改動,筆者將會及時更改。使用開源已經有好幾年的時間了,一直沒有時間和精力來具體研究某個開源項目的具體實現,這次是第一次寫開源項目的源碼分析,如果文中有錯誤的地方,歡迎讀者可以留言指出。對于轉載的讀者,請注明文章的出處。
希望和廣大的開發者/開源愛好者進行交流,歡迎大家的留言和討論。
-----------------------------------------------------
Silence, the way to avoid many problems;
Smile, the way to solve many problems;