请问在NETTY中
try {
// 7 监听通道关闭事件
// 应用程序会一直等待,直到channel关闭
ChannelFuture closeFuture = channelFuture.channel().closeFuture() ;
closeFuture.sync() ;
} catch (Exception e) {
e.printStackTrace() ;
log.error("发生其他异常", e) ;
} finally {
// 8 优雅关闭EventLoopGroup,
// 释放掉所有资源包括创建的线程****
bossGroup.shutdownGracefully() ;
workGroup.shutdownGracefully() ;
}
在以上代码中
1、ChannelFuture closeFuture = channelFuture.channel().closeFuture() 这句话,是channelFuture.channel().closeFuture()中的closeFuture() 执行后返回一个Future给 前面定义的 ChannelFuture closeFuture ,还是 ChannelFuture closeFuture就是channelFuture.channel().closeFuture()
2、.closeFuture() 是 channelFuture.channel().closeFuture() 这句代码中立即执行,还是在其他什么情况下执行。