Ejemplo n.º 1
0
  /**
   * Disconnects this client, and returns either when the connection is closed or the timeout
   * expires, which ever comes first.
   */
  public void disconnect() {
    System.err.println(toString() + " disconnecting");

    synchronized (lock) {
      if (!connected) {
        return;
      }
      try {
        connection.close();
        lock.wait(WAIT_TIME);
      } catch (Exception e) {
        System.err.println(toString() + " disconnect exception:" + e);
        lock.notifyAll();
      } finally {
        if (connected) {
          reset();
        }
      }
    }
  }