• shuts down an ExecutorService in two phases, first by calling shutdown to reject incoming tasks, and then calling shutdownNow, if necessary, to cancel any lingering tasks: 
  •  void shutdownAndAwaitTermination(ExecutorService pool) {
    pool.shutdown(); // Disable new tasks from being submitted
    try {
    // Wait a while for existing tasks to terminate
    if (!pool.awaitTermination(60, TimeUnit.SECONDS)) {
    pool.shutdownNow(); // Cancel currently executing tasks
    // Wait a while for tasks to respond to being cancelled
    if (!pool.awaitTermination(60, TimeUnit.SECONDS))
    System.err.println("Pool did not terminate");
    }
    } catch (InterruptedException ie) {
    // (Re-)Cancel if current thread also interrupted
    pool.shutdownNow();
    // Preserve interrupt status
    Thread.currentThread().interrupt();
    }
    }

最新文章

  1. js的并行加载以及顺序执行
  2. filterHTML
  3. hibernate查询返回一个list ,Date类型追加数据
  4. 【leetcode】Integer to Roman
  5. JAVA的覆盖、继承和多态的详细解说.this和super的用法
  6. 如何让CRectTracker的m_rect不超出一定的范围,比如screen或者某个document的范围
  7. 基于anyrtc的sdk实现直播连麦互动
  8. 原始启动log&新log
  9. Java中@Deprecated、@SupressWarning、@Override的作用
  10. wifi基本原理
  11. python连接Linux命令行
  12. 置信区间-显著性-P-值
  13. gcc ld 链接器相关知识,调试指令(程序员的自我修养----链接、装载与库)
  14. ubuntu 18.04//18.10&&windows 7/10双系统系统时间不一致
  15. LeetCode(72):编辑距离
  16. 【转】Python中的字符串与字符编码
  17. [No0000118]SQL Server附加数据库拒绝访问解决方法汇总
  18. pyautogui控制鼠标键盘自动填写数据
  19. VS2017 加载项目 :未找到框架“.NETFramework,Version=v4.7”的引用程序集(出坑指南)
  20. Centos6.6系统root用户密码恢复案例(转)

热门文章

  1. smokeping插件使用及说明
  2. attr/attrs模块
  3. Mysql 的存储引擎,myisam和innodb的区别。
  4. 12 nginx URL 重写 ecshop案例
  5. C#下的摄像机标定
  6. python 基础 2.3 for 循环
  7. wmiprvse.exe 进程占CPU过高 问题解决
  8. Entity Framework 4.1:多对多的关系
  9. 通用分页(Jquery版)
  10. mysql的分库分表