线程池shutdownNow源码

本文详细探讨了线程池的shutdownNow方法,分析了其实现原理及内部状态转换过程,帮助理解线程池的停止机制。
摘要由CSDN通过智能技术生成
 /**
     * 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.
     * 尝试停止所有正在执行的任务,终止等待中的任务,并且返回一个等待执行的任务的list。
     * 当此方法返回时,将从任务队列中删除这些任务
     * <p>This method does not wait for actively executing tasks to
     * terminate.  Use {@link #awaitTermination awaitTermination} to
     * do that.
     * 此方法不会等待正在执行的任务停止,要达到此效果,需使用awaitTermination
     * <p>There are no guarantees beyond best-effort attempts to stop
     * processing actively executing tasks.  This implementation
     * cancels tasks via {@link Thread#interrupt}, so any task that
     * fails to respond to interrupts may never terminate.
     * 此方法只是尽力尝试终止正在执行的任务,并不保证一定能终止。
     * 是通过 Thread#interrupt方法来完成取消任务,因此任何不响应中断的任务可能永远不会终止运行
     * @t
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值