2012-04-11 109 views

回答

1

代码似乎缺少调用实际关闭通道。我相信你想线路14

0

前实际调用Channel.close()我这样做在我的代码:

public class TimeClient { 
    public static void main(String[] args) throws Exception { 
     ... 
     ChannelFactory factory = ...; 
     ClientBootstrap bootstrap = ...; 
     ... 
     ChannelFuture future(29) = bootstrap.connect(...); 
     future.awaitUninterruptibly();(30) 
     if (!future.isSuccess()) { 
      future.getCause().printStackTrace();(31) 
     } 
     ... YOUR BUSINESS LOGIC HERE 
     future.getChannel().close().awaitUninterruptibly();(32) 
     factory.releaseExternalResources();(33) 
    } 
}