code: public void close() {
      /**
       * Set closed flag and notify all threads to check their conditions.
       * Should result in dispatcher terminating.
       */
      synchronized (buffer) {
        closed = true;
        buffer.notifyAll();
      }
  
      try {
        dispatcher.join();
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        org.apache.log4j.helpers.LogLog.error(
          "Got an InterruptedException while waiting for the "
          + "dispatcher to finish.", e);
      }
  
      //
      //    close all attached appenders.
      //
      appenders.closeAppenders();
    }
docs: Close this <code>AsyncAppender</code> by interrupting the dispatcher
  thread which will process all pending events before exiting.