Executors简单使用
来源:互联网 发布:附近编程培训班 编辑:程序博客网 时间:2024/06/11 00:43
public class ExecutorTest { private static Integer num = 1; private static boolean exeFlag = true; public static void main(String[] args) throws InterruptedException { ExecutorService executorService = Executors.newFixedThreadPool(10);//初始化10个 超过10个堵塞 while (exeFlag){ if(num <=100){ executorService.execute(new Runnable() { @Override public void run() { System.out.println("第"+ num +"个"); num++; } }); }else{ if(((ThreadPoolExecutor)executorService).getActiveCount()==0){ executorService.shutdown();//关闭executors exeFlag=false; System.out.println("任务结束!"); } } Thread.sleep(10); } }}
阅读全文
0 0
- Executors简单使用
- Executors多线程的简单使用
- 使用Executors
- ExecutorService,Executors 使用
- 使用Executors和ThreadPoolExecutor2
- JAVA中的Executors使用
- Executors
- Executors
- Executors
- Executors
- Executors
- Executors
- Executors
- Executors
- Executors
- Executors
- Executors
- Executors
- 如何将结婚当作项目来管理
- Java中 getClass()和super.getClass()
- <2>——Add Two Numbers
- Shell中read的用法详解
- checkbo自定义样式
- Executors简单使用
- NFS服务器的配置和autofs自动挂载
- 常用数学函数
- Jekyll简明教程(一)安装
- 对多元化发展的两点简单思考
- 多标签图像分类任务的评价方法——mAP
- java 获取本年本月或前月的第一天和最后一天
- mybatis报错does not contain value for
- keras中文文档笔记9——关于keras层