@Override
 public void run() {
   try {
     while (!shutdown) {
       synchronized (this) {
         wait(5000);
         // Close expired connections
         connMgr.closeExpiredConnections();
         // Optionally, close connections that have been idle longer than 30 sec
         connMgr.closeIdleConnections(30, TimeUnit.SECONDS);
       }
     }
   } catch (InterruptedException ex) {
     // terminate
   }
 }
  @Scheduled(fixedRate = 20000)
  public void httpConnectionRelease() {
    PoolingHttpClientConnectionManager connectionManager =
        (PoolingHttpClientConnectionManager)
            ContextLoader.getCurrentWebApplicationContext().getBean("httpPoolManager");
    if (logger.isInfoEnabled()) {
      logger.info(
          "release start connect count:=" + connectionManager.getTotalStats().getAvailable());
    }
    // Close expired connections
    connectionManager.closeExpiredConnections();
    // Optionally, close connections
    // that have been idle longer than readTimeout*2 MILLISECONDS
    connectionManager.closeIdleConnections(60000, TimeUnit.MILLISECONDS);

    if (logger.isInfoEnabled()) {
      logger.info("release end connect count:=" + connectionManager.getTotalStats().getAvailable());
      logger.info("release end connect count:=" + connectionManager.getTotalStats().getMax());
    }
  }
 @Override
 public void run() {
   try {
     // Holds the stop request that stopped the process.
     Stop stopRequest;
     // Every 5 seconds.
     while ((stopRequest = stopSignal.poll(5, TimeUnit.SECONDS)) == null) {
       // Close expired connections
       cm.closeExpiredConnections();
       // Optionally, close connections that have been idle too long.
       cm.closeIdleConnections(60, TimeUnit.SECONDS);
       // Look at pool stats.
       logger.debug("Stats: {}", cm.getTotalStats());
     }
     // Acknowledge the stop request.
     stopRequest.stopped();
   } catch (InterruptedException ex) {
     // terminate
   }
 }