private void ClientThreadRun() throws IOException {
  SocketChannel channel=null;
  try {
    log.debug("Attempting connection to {}:{} with {} pending messages",hostname,port,pending.size());
    channel=SocketChannel.open(new InetSocketAddress(hostname,port));
    channel.configureBlocking(false);
    ClientThreadMainLoop(channel);
  }
  finally {
    if (channel != null) {
      channel.close();
    }
    if (current != null) {
      pending.offerFirst(current);
      current=null;
    }
  }
}

private void ClientThreadRun ( ) throws IOException { SocketChannel channel = null ; try { log . debug ( "Attempting connection to {}:{} with {} pending messages" , hostname , port , pending . size ( ) ) ; channel = SocketChannel . open ( new InetSocketAddress ( hostname , port ) ) ; channel . configureBlocking ( false ) ; ClientThreadMainLoop ( channel ) ; } finally { if ( channel != null ) { channel . close ( ) ; } if ( current != null ) { pending . offerFirst ( current ) ; current = null ; } } }
establishes a connection to the server , then runs the client thread main loop returns if connection fails or if the connection is interrupted
