有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

调用channelInactive后的java链操作

我有一些清理代码:

public void channelInactive(ChannelHandlerContext ctx) throws Exception {
    clean-up code
    super.channelInactive(ctx);
}

有时,我需要主动断开通道:

ChannelFuture f = channel.disconnect();
f.addListener(new ChannelFutureListener() {
     public void operationComplete(ChannelFuture future) {
         // the problem is the channelInactive might not be called yet
         // how can I make sure channelInactive has been called?
         do something but the clean-up code in channelInactive MUST be called
     }
});

共 (0) 个答案