org.apache.tomcat.util.threads.ThreadPoolExecutor.shutdown()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.apache.tomcat.util.threads.ThreadPoolExecutor.shutdown()方法的一些代码示例,展示了ThreadPoolExecutor.shutdown()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadPoolExecutor.shutdown()方法的具体详情如下:
包路径:org.apache.tomcat.util.threads.ThreadPoolExecutor
类名称:ThreadPoolExecutor
方法名:shutdown

ThreadPoolExecutor.shutdown介绍

暂无

代码示例

代码示例来源:origin: testIT-LivingDoc/livingdoc-core

@Override
public void onApplicationEvent(ContextClosedEvent event) {
  this.connector.pause();
  log.info("Shutting Down LivingDoc Remote Agent");
  Executor executor = this.connector.getProtocolHandler().getExecutor();
  if (executor instanceof ThreadPoolExecutor) {
    try {
      ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executor;
      threadPoolExecutor.shutdown();
      if (!threadPoolExecutor.awaitTermination(30, TimeUnit.SECONDS)) {
        log.warn("Tomcat thread pool did not shut down gracefully within "
            + "30 seconds. Proceeding with forceful shutdown");
      }
    } catch (InterruptedException ex) {
      Thread.currentThread().interrupt();
    }
  }
}

代码示例来源:origin: lord-of-code/loc-framework

threadPoolExecutor.shutdown();
if (!threadPoolExecutor
  .awaitTermination(tomcatGracefulShutdownProperties.getWaitTime(), TimeUnit.SECONDS)) {

代码示例来源:origin: corentin59/spring-boot-graceful-shutdown

/**
 * Perform a shutdown
 * @param delay is delay to force is the delay before perform a force shutdown
 * @throws InterruptedException if we have an exception
 */
public void shutdown(Integer delay) throws InterruptedException {
  // Used to properly handle the work queue.
  final Executor executor = connector.getProtocolHandler().getExecutor();
  final ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executor;
  /*
   * Initiates an orderly shutdown in which previously submitted
   * tasks are executed, but no new tasks will be accepted.
   * Invocation has no additional effect if already shut down.
   */
  threadPoolExecutor.shutdown();
  // We wait after the end of the current requests
  if(!threadPoolExecutor.awaitTermination(delay, TimeUnit.SECONDS)) {
    logger.warn("Tomcat thread pool did not shut down gracefully within " + delay + " second(s). Proceeding with force shutdown");
  } else {
    logger.debug("Tomcat thread pool is empty, we stop now");
  }
}

相关文章