ExecutorService的shutdown
来源:互联网 发布:python搭建web服务器 编辑:程序博客网 时间:2024/06/07 04:53
之前一直困惑代码注释中的这段话。
This method does not wait for previously submitted tasks to
complete execution. Use {@link #awaitTermination awaitTermination}
to do that.
理解能力捉急,这里的不等待不是不让线程池中的任务执行完。。。
shutdown只是阻止新任务加入到队列中,它仍然会让已经执行的以及在就绪队列中的任务接下来执行,只不过主线程不会阻塞下来等剩下的线程来执行。
验证:
executor.shutdown();
while(!executor.isTerminated()){
System.out.println("Not finished");
}
会打印若干Not finished然后跳出循环。
让主线程等待剩下线程执行的方法是.awaitTermination
0 0
- ExecutorService的shutdown
- 关于ExecutorService的shutdown()方法
- ExecutorService对象的shutdown()和shutdownNow()的区别
- ExecutorService对象的shutdown()和shutdownNow()的区别
- ExecutorService对象的shutdown()和shutdownNow()的区别
- ExecutorService对象的shutdown()和shutdownNow()的区别
- ExecutorService对象的shutdown()和shutdownNow()的区别
- 线程服务ExecutorService的操作shutdown方法和shutdownNow方法
- Java多线程ExecutorService.shutdown什么时候执行
- ExecutorService.shutdown()应该是在线程执行完毕后,才会去关闭
- ExecutorService——shutdown方法和awaitTermination方法
- FutureTask、ExecutorService的使用
- ExecutorService的任务调度
- ExecutorService的API
- 关于ExecutorService 的用法
- ExecutorService 的使用
- ExecutorService的OOM坑
- ExecutorService的具体实例
- CommonUtil.getXXX(Context context),Context对象你传对了吗?
- C语言第五课 字符串的
- spark一千篇旅游日记0009 之 spark小例子程序03
- map方法学习,封装函数--实现Array.prototype.map()的功能
- 站在巨人的肩膀上—英语
- ExecutorService的shutdown
- fir.im Log Guru 正式开源,快速找到 iOS 应用无法安装的原因
- Problem A: 第一个类
- Linux根文件之lib库制作详解
- Mysql数据库更新操作导致死锁问题
- C语言数据结构——子串在主串中的定位函数
- Eigen3.3.3安装配置+VS2015+Cmake
- Problem B: 建造一间教室
- MATLAB测试机器零阈值的大小