当前位置:网站首页>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");
}
}
边栏推荐
- Phaser(一):平台跳跃收集游戏
- Working principle and application of fast recovery diode
- 10、 Interceptor
- What is the real HTAP? (1) Background article
- Kubernetes 进阶训练营 调度器
- 【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(八)
- columns in GROUP BY clause; this is incompatible with sql_ mode=only_ full_ group_ By mysql8.0 solution
- Calculate the curvature of discrete points (matlab)
- Kubernetes advanced training camp scheduler
- Have you known several distribution methods of NFT? What are the advantages and disadvantages of different distribution methods?
猜你喜欢

Face database collection summary

STM32 development | ad7606 parallel multi-channel data acquisition

滑动窗口——leetcode题解

Phaser(一):平台跳跃收集游戏

Phaser (I): platform jumping collection game

UE4 two ways to obtain player control

二、国际知名项目-HelloWorld

What are the demand management software for small and medium-sized enterprises

Minipcie interface can card solves the problem of industrial computer expanding can channel minipcie can

data warehouse
随机推荐
C语言——字符串函数,内存函数集锦以及模拟实现
What are the demand management software for small and medium-sized enterprises
2022河南萌新联赛第(三)场:河南大学 B - 逆序对计数
Briefly describe the application fields of WMS warehouse management system
批量将PPM格式图片转化为JPG格式
[mathematical modeling] basic knowledge of MATLAB
Ggjj, do you have a look at this problem? Does caching cause cross domain problems?
三、@RequestMapping注解
这种是我的vs没连上数据库吗
Use field parameters for report translation
autocomplete禁止表单自动填充
columns in GROUP BY clause; this is incompatible with sql_ mode=only_ full_ group_ By mysql8.0 solution
UE4 two ways to obtain player control
There was an unexpected error (type=Method Not Allowed, status=405).记录报错
补位,稍后补上
SQL encryption and decryption injection details
Spark Structured Streaming HelloWorld
2022 Henan Mengxin League game (3): Henan University L - synthetic game
Whether the SQL that fails to execute MySQL is counted into the slow query?
YAPI安装