2012-04-11 111 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) 
    } 
}