当前位置:网站首页>CountLaunch Demo的测试
CountLaunch Demo的测试
2022-07-26 04:57:00 【知识浅谈】
public class Test {
//CountLaunch demo 指定6个线程执行完后才能达到条件,继续向下进行
// 处理文件的数量
private static final int threadCount = 6;
public static void main(String[] args) throws InterruptedException {
// 创建一个具有固定线程数量的线程池对象(推荐使用构造方法创建)
ExecutorService threadPool = Executors.newFixedThreadPool(10);
final CountDownLatch countDownLatch = new CountDownLatch(threadCount);
for (int i = 0; i < threadCount; i++) {
final int threadnum = i;
threadPool.execute(() -> {
try {
//处理文件的业务操作
Thread.sleep(2);
//......
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
//表示一个文件已经被完成
countDownLatch.countDown();
}
});
}
countDownLatch.await();
threadPool.shutdown();
System.out.println("finish");
}
}
边栏推荐
- Character function and string function (I)
- User defined type details
- Leetcode - monotone stack and monotone queue
- STM32 development | ad7606 parallel multi-channel data acquisition
- 3、 @requestmapping annotation
- C language lseek() function: move the read and write location of the file
- 七、RESTful
- C语言——字符串函数,内存函数集锦以及模拟实现
- Vector explanation and iterator failure
- LeetCode - 单调栈与单调队列
猜你喜欢

What are the characteristics of the grammar of Russian documents in the translation of scientific papers

Axi protocol (5): burst mechanism of Axi protocol

自动化测试框架该如何搭建?

Principle of image nonlocal mean filtering

Interprocess communication

Use Baidu PaddlePaddle easydl to complete garbage classification

创建MySQL数据库的两种方式

What points should be paid attention to in the selection of project management system?

Customer service relationship management based on SQL net enterprise messenger enterprise communications

The integrated real-time HTAP database stonedb, how to replace MySQL and achieve nearly 100 times the improvement of analysis performance
随机推荐
一个sql server查询截止某个日期最新的记录
Codeforces Round #807 (Div. 2)
Fill in the vacancy, and fill in later
Axi protocol (5): burst mechanism of Axi protocol
What are the characteristics of the grammar of Russian documents in the translation of scientific papers
UE4 controls the rotation of objects by pressing keys
vector详解和迭代器失效问题
The integrated real-time HTAP database stonedb, how to replace MySQL and achieve nearly 100 times the improvement of analysis performance
Study of const of constant function
Spark Structured Streaming HelloWorld
"Game engine light in light out" 4. shader
STM32 development | ad7606 parallel multi-channel data acquisition
MySQL 执行失败的sql是否会计入慢查询?
Good at C (summer vacation daily question 6)
LeetCode - 单调栈与单调队列
Can serial port can 232 can 485 serial port to CANbus bus gateway module can232/485mb converter cancom
9、 File upload and download
2022 Hangdian multi school DOS card (line segment tree)
2022河南萌新联赛第(三)场:河南大学 B - 逆序对计数
can 串口 can 232 can 485 串口转CANbus总线网关模块CAN232/485MB转换器CANCOM