• 【多线程】线程池关闭


    shutdown(): 已添加的任务会继续执行完毕,但是不会阻塞;新任务无法继续添加

    • 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.

      This method does not wait for previously submitted tasks to complete execution. Use awaitTermination to do that.

    public List<Runnable> shutdownNow(): 在调用shutdownNow()方法后,线程池会立即关闭,未执行的任务会以列表的形式返回。

      Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution. These tasks are drained (removed) from the task queue upon return from this method.

      This method does not wait for actively executing tasks to terminate. Use awaitTermination to do that.

      There are no guarantees beyond best-effort attempts to stop processing actively executing tasks. This implementation cancels tasks via Thread.interrupt(), so any task that fails to respond to interrupts may never terminate.

    awaitTermination


    shutdownNow

      

     shutdown: 原有任务继续执行完毕,新任务无法继续执行

      

  • 相关阅读:
    读TIJ -2 一切都是对象
    codeforces 437C The Child and Toy
    关于js基础easy忘记的那些事儿
    项目启动会应该注意的几点
    SSH-Struts(一)——基本原理
    公益代理-开发人员的福音
    【手打】LZW编码的C/C++实现
    tab group of firefox
    Sort Colors -- LeetCode
    Qt 学习之路:自定义事件
  • 原文地址:https://www.cnblogs.com/clarino/p/15513646.html
Copyright © 2020-2023  润新知