当前位置:网站首页>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();
}
边栏推荐
- mysql简单安装
- MySQL Leak Detection and Filling (2) Sorting and Retrieval, Filtering Data, Fuzzy Query, Regular Expression
- 批量修改Shapefile属性表的一种方法(使用gdal.jar)
- 有返回值的函数
- Another implementation of lateral view explode
- 关于一次性通过CISSP考试的一点经验分享
- 自动化测试框架有哪几种?搭建的思路是什么?一篇文章让你彻底了解自动化
- 接口测试的基础流程和用例设计方法你知道吗?
- [Personal study summary] CRC verification principle and implementation
- 3.练习Thread
猜你喜欢
【机器学习】数据科学基础——机器学习基础实践(二)
软件测试面试中,面试官问你一些比较“刁难”的问题你会怎么回答
白盒测试的概念、目的是什么?及主要方法有哪些?
本体开发日记05-努力理解SWRL(Built-Ins)
软件测试分析流程及输出项包括哪些内容?
[Personal study summary] CRC verification principle and implementation
银联最新测试工程师笔试题目,你能得多少分?
米斗APP逆向分析
使用Protege4和CO-ODE工具构建OWL本体的实用指南-1.3版本(7.4 Annotation Properties-注释属性)
Command line query database
随机推荐
有返回值的函数
本体开发日记05-努力理解SWRL(RDF Concrete Syntax)
LPP code and its comments
常用功能测试的检查点与用例设计思路
[Personal study summary] CRC verification principle and implementation
本体开发日记03-排错进行时
2. Byte stream
div模拟textarea文本框,输入文字高度自适应,且实现字数统计和限制
A Practical Guide to Building OWL Ontologies using Protege4 and CO-ODE Tools - Version 1.3 (7.4 Annotation Properties - Annotation Properties)
.equals ==
"The camera can't be used" + win8.1 + DELL + external camera + USB drive-free solution
3.List接口与实现类
pycharm在创建py文件时如何自动注释
批量修改Shapefile属性表的一种方法(使用gdal.jar)
How much do you know about the mobile APP testing process specifications and methods?
字典
Summary of steps and methods for installing and uninstalling test cases that you must read
Ontology development diary 02 - simple sparql query
1. Introduction to threads
Cisco common basic configuration of common commands