当前位置:网站首页>多线程实现循环
多线程实现循环
2022-07-27 15:54:00 【@淡 定】
public void main( List<String> list) {
List<String> a=new ArrayList<>();
//自定义线程池
ExecutorService pool=new ThreadPoolExecutor(5,10,
1L, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(3),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.AbortPolicy());
final CountDownLatch endGate = new CountDownLatch(list.size());
for (int i = 0; i < list.size(); i++) {
String str = list.get(i);
Runnable run = new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
//具体操作
} catch (Exception e) {
e.printStackTrace();
}finally {
endGate.countDown();
}
}
};
pool.execute(run);
//pool.submit(run);
}
try {
endGate.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
pool.shutdown();
System.out.println("结束!");
return a;
}
边栏推荐
- What are the safety risks of small games?
- Oracle 11g database installation tutorial
- 树莓派驱动代码的编译和测试
- Evaluation index of machine learning (II) -- classification evaluation index
- 【数据库系统概论(王珊)】第5章——数据库完整性
- 知物由学 | 从0到1搭建实时反外挂机制,多维度补充手游攻防力
- Yanrong technology was selected as Beijing's "specialized and innovative" in 2022 to lead hybrid cloud file storage
- JS to realize the right-click menu bar function
- TCP的连接状态标识 (SYN, FIN, ACK, PSH, RST, URG)
- How to learn C language? This article gives you the complete answer
猜你喜欢

快解析结合海典医药

卷积神经网络——从R-CNN,Fast R-CNN到Faster R-CNN,Mask R-CNN

How difficult the interview is! I was forced to survive the six rounds of interview of ant financial! Almost out (interview resumption)

Establishing SSL connection without server‘s identity verification is not recommended

I got the P8 "top-level" distributed architecture manual crazy spread on Alibaba intranet

卷积神经网络之卷积计算过程个人理解

工信部再治数据安全,网易易盾“隐私合规”守住企业经营底线

知物由学 | 易盾自研文本实时聚类技术,一网打尽社交网络中的同类有害内容

Original direct selling MOS tube knl42150 2.8a/1500v applicable photovoltaic inverter can provide samples
How to improve the security of Android applications?
随机推荐
知物由学 | APP大瘦身,新一代AAB框架下的安全加固之道
js实现右键菜单栏功能
微信小程序 云函数批量删除多条数据 Error: errCode: -502005 database collection not exists
6月第1周易盾业务风控关注 | 新东方学而思等15家机构被顶格罚款
Evaluation index of machine learning (II) -- classification evaluation index
Summer Challenge [FFH] real time chat room websocket practice
卷积神经网络——YOLOV1论文翻译
How difficult the interview is! I was forced to survive the six rounds of interview of ant financial! Almost out (interview resumption)
Could not obtain transaction-synchronized Session for current thread
知物由学 | 从0到1搭建实时反外挂机制,多维度补充手游攻防力
What are the safety risks of small games?
【Codeforces】 A. Computer Game
Initial polymorphism
golang 等待一组goroutine完成,并带返回值(2)
初识多态
7月第4周易盾业务风控关注 | 最高法对APP强索个人信息进行规制
防止sql注入
JS to realize the right-click menu bar function
面试常见问题一二
Know things by learning | build a real-time anti plug-in mechanism from 0 to 1 to supplement the offensive and defensive power of mobile games in multiple dimensions