当前位置:网站首页>Thread,Runnable,ExecutorService线程池控制下线程量
Thread,Runnable,ExecutorService线程池控制下线程量
2022-08-09 09:28:00 【潇湘梦】
Thread线程池简单手工搞一波写个理解下
public class Souprint extends Thread implements Runnable {
private Integer sysPint;
public Souprint(Integer pint) {
this.sysPint = pint;
}
@Override
public void run() {
try {
System.out.println("参数:"+sysPint + "线程打印 ThreadName:"+Thread.currentThread().getName()+" ID:"+Thread.currentThread().getId());
Thread.sleep(3);
System.out.println("休眠后 线程打印 ThreadName:"+Thread.currentThread().getName()+" ID:"+Thread.currentThread().getId());
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
@Test
public void testThead() {
//创建一个线程池
ExecutorService exe = Executors.newFixedThreadPool(4);
String[] str = new String[]{
"1", "2", "3", "4"};
for (String s : str) {
int sssss = Integer.parseInt(s);
System.out.println(sssss);
exe.execute(new Thread(new Souprint(sssss)));
}
exe.shutdown();
}
边栏推荐
猜你喜欢

本体开发日记01-Jena配置环境变量

在anaconda环境中配置cuda和cudnn
选择黑盒测试用例设计方法的综合策略方案总结
软件测试外包公司怎么样?有什么好处和坏处?为什么没人去?
Ontology Development Diary 03 - When debugging is in progress

本体开发日记05-努力理解SWRL(中)

接口测试的基础流程和用例设计方法你知道吗?
单元测试是什么?怎么写?主要测试什么?

记录一次被入侵5900端口经历

How much do you know about the mobile APP testing process specifications and methods?
随机推荐
本体开发日记04-努力理解protege的某个方面
软件测试的流程规范有哪些?具体要怎么做?
接口设计
6.File类
命令行查询数据库
常用命令之思科常用基础配置
自动化测试框架有哪几种?搭建的思路是什么?一篇文章让你彻底了解自动化
JS报错-Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on...
m个样本的梯度下降
Sweet alert
5.Set接口与实现类
Go-指针的那些事
测试计划包括哪些内容?目的和意义是什么?
记录一次被入侵5900端口经历
WAVE SUMMIT 2022深度学习开发者峰会
批量修改Shapefile属性表的一种方法(使用gdal.jar)
China to create a domestic "Google Earth" clarity scary
一个项目的整体测试流程有哪几个阶段?测试方法有哪些?
goproxy.io 证书过期
5.转换流