@Override synchronized public void shutdown(){
  if (!isOpen())   return;
  open=false;
  if (log.isInfoEnabled())   log.info("begin");
  final long begin=System.currentTimeMillis();
  final long shutdownTimeout=this.shutdownTimeout == 0L ? Long.MAX_VALUE : this.shutdownTimeout;
  final TimeUnit unit=TimeUnit.MILLISECONDS;
  txWriteService.shutdown();
  readService.shutdown();
  writeService.shutdown();
  if (sampleService != null)   sampleService.shutdown();
  try {
    if (log.isInfoEnabled())     log.info("Awaiting transaction service termination");
    final long elapsed=System.currentTimeMillis() - begin;
    if (!txWriteService.awaitTermination(shutdownTimeout - elapsed,unit)) {
      log.warn("Transaction service termination: timeout");
    }
  }
 catch (  InterruptedException ex) {
    log.warn("Interrupted awaiting transaction service termination.",ex);
  }
  try {
    if (log.isInfoEnabled())     log.info("Awaiting read service termination");
    final long elapsed=System.currentTimeMillis() - begin;
    if (!readService.awaitTermination(shutdownTimeout - elapsed,unit)) {
      log.warn("Read service termination: timeout");
    }
  }
 catch (  InterruptedException ex) {
    log.warn("Interrupted awaiting read service termination.",ex);
  }
  try {
    final long elapsed=System.currentTimeMillis() - begin;
    final long timeout=shutdownTimeout - elapsed;
    if (log.isInfoEnabled())     log.info("Awaiting write service termination: will wait " + timeout + "ms");
    if (!writeService.awaitTermination(timeout,unit)) {
      log.warn("Write service termination : timeout");
    }
  }
 catch (  InterruptedException ex) {
    log.warn("Interrupted awaiting write service termination.",ex);
  }
  final long elapsed=System.currentTimeMillis() - begin;
  if (log.isInfoEnabled())   log.info("Done: elapsed=" + elapsed + "ms");
}

@ Override synchronized public void shutdown ( ) { if ( ! isOpen ( ) ) return ; open = false ; if ( log . isInfoEnabled ( ) ) log . info ( "begin" ) ; final long begin = System . currentTimeMillis ( ) ; final long shutdownTimeout = this . shutdownTimeout == 0L ? Long . MAX_VALUE : this . shutdownTimeout ; final TimeUnit unit = TimeUnit . MILLISECONDS ; txWriteService . shutdown ( ) ; readService . shutdown ( ) ; writeService . shutdown ( ) ; if ( sampleService != null ) sampleService . shutdown ( ) ; try { if ( log . isInfoEnabled ( ) ) log . info ( "Awaiting transaction service termination" ) ; final long elapsed = System . currentTimeMillis ( ) - begin ; if ( ! txWriteService . awaitTermination ( shutdownTimeout - elapsed , unit ) ) { log . warn ( "Transaction service termination: timeout" ) ; } } catch ( InterruptedException ex ) { log . warn ( "Interrupted awaiting transaction service termination." , ex ) ; } try { if ( log . isInfoEnabled ( ) ) log . info ( "Awaiting read service termination" ) ; final long elapsed = System . currentTimeMillis ( ) - begin ; if ( ! readService . awaitTermination ( shutdownTimeout - elapsed , unit ) ) { log . warn ( "Read service termination: timeout" ) ; } } catch ( InterruptedException ex ) { log . warn ( "Interrupted awaiting read service termination." , ex ) ; } try { final long elapsed = System . currentTimeMillis ( ) - begin ; final long timeout = shutdownTimeout - elapsed ; if ( log . isInfoEnabled ( ) ) log . info ( "Awaiting write service termination: will wait " + timeout + "ms" ) ; if ( ! writeService . awaitTermination ( timeout , unit ) ) { log . warn ( "Write service termination : timeout" ) ; } } catch ( InterruptedException ex ) { log . warn ( "Interrupted awaiting write service termination." , ex ) ; } final long elapsed = System . currentTimeMillis ( ) - begin ; if ( log . isInfoEnabled ( ) ) log . info ( "Done: elapsed=" + elapsed + "ms" ) ; }
shutdown the thread pools ( running tasks will run to completion , but no new tasks will start ) .
