private synchronized void checkShutDownProxyBridge(){
  if (proxyServer != null) {
    smtpRequestsPhaser.arriveAndDeregister();
    LOGGER.trace("SMTP request threads left: {}",smtpRequestsPhaser.getUnarrivedParties());
    if (smtpRequestsPhaser.getUnarrivedParties() == 0) {
      LOGGER.trace("all threads have finished processing");
      if (proxyServer.isRunning() && !proxyServer.isStopping()) {
        LOGGER.trace("stopping proxy bridge...");
        proxyServer.stop();
      }
      if (executor != null) {
        executor.shutdown();
      }
    }
  }
}

private synchronized void checkShutDownProxyBridge ( ) { if ( proxyServer != null ) { smtpRequestsPhaser . arriveAndDeregister ( ) ; LOGGER . trace ( "SMTP request threads left: {}" , smtpRequestsPhaser . getUnarrivedParties ( ) ) ; if ( smtpRequestsPhaser . getUnarrivedParties ( ) == 0 ) { LOGGER . trace ( "all threads have finished processing" ) ; if ( proxyServer . isRunning ( ) && ! proxyServer . isStopping ( ) ) { LOGGER . trace ( "stopping proxy bridge..." ) ; proxyServer . stop ( ) ; } if ( executor != null ) { executor . shutdown ( ) ; } } } }
we need to keep a count of running threads only if we need to shutdown the proxy bridging server at the end in async mode . < p > proxyserver ! = null means we need to shut down server , registered parties means we ' re running in async ( batch ) mode
