1
我讀了Netty的頻道的Javadoc:http://netty.io/4.0/api/io/netty/channel/Channel.html訂購的多通道#寫
在我的單線程(Netty中的IO線程外),如果我叫Channel#write
很多次:
channel.write(msg1);
channel.write(msg2);
channel.write(msg3);
Will Netty會確保消息按順序輸出:msg1,msg2,msg3? 或者我必須手動確保訂單(非常單調乏味,非常難看)?
ChannelFuture f1 = channel.write(msg1);
f1.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture future) {
ChannelFuture f2 = channel.write(msg2);
f2.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture future) {
channel.write(msg3);
}
});
}
});