当前位置:网站首页>How to reasonably estimate the size of thread pool
How to reasonably estimate the size of thread pool
2022-07-23 22:29:00 【InfoQ】
CPU intensive
public class SrcTest {
static int threadNum = 20;
final static int taskNum = 200;
static ExecutorService executorService = Executors.newFixedThreadPool(threadNum);
static CountDownLatch endGate = new CountDownLatch(taskNum);
public static void main(String[] args) throws InterruptedException {
long start = System.currentTimeMillis();
for (int i = 0; i< taskNum; i++){
executorService.submit(cpuCal());
}
endGate.await();
long end = System.currentTimeMillis();
System.out.println(" Number of thread pools :"+threadNum+" CPU Check the number :"+Runtime.getRuntime().availableProcessors()+" It's all over :time:"+(end-start));
}
public static Thread cpuCal(){
return new Thread(()->{
long start = System.currentTimeMillis();
// Write something about it cpu Time consuming operations
for (int i = 0;i<10000000;i++){
StringBuffer sb = new StringBuffer();
sb.append(i).append(",");
}
long end = System.currentTimeMillis();
System.out.println(" Threads ID:"+Thread.currentThread().getId()+"; Elapsed time :"+(end-start));
endGate.countDown();
});
}
}
Execution results








Icon results

sysctl hw.physicalcpusysctl hw.logicalcpuCome to the conclusion
IO intensive
experiment ( A little )
mixed type
Why does thread context switching cost performance
The concept of context switching
Loss caused by context switching
Reference documents

边栏推荐
- [golang learning notes] simple use of flag package, command line parsing
- zk 是如何解决脑裂问题的
- LeetCode高频题53. 最大子数组和,具有最大和的连续子数组,返回其最大和
- TikTok推出多语种字幕和翻译工具
- Programming in the novel [serial 18] the moon bends in the yuan universe
- 10道面试基础笔试题,你能对几题?
- Programming in the novel [serial 16] the moon bends in the yuan universe
- Programming in the novel [serial 17] the moon bends in the yuan universe
- D2admin framework is basically used
- 众邦科技又一潜心力作 —— 陀螺匠 OA 系统
猜你喜欢

Linked list - 203. remove linked list elements

02. Supplement of knowledge related to web page structure

Investment suggestions for overseas senior players (3) 2021-05-04

How ZK solves the problem of cerebral fissure

D2admin framework is basically used

大淘营批量采集商品,如何将未上传的宝贝保存下来等后面再导入采集上传

Cookies and sessions

达梦数据库tools包中的工具(操作达梦数据库)

Explain NAT technology in detail

Record the process of the first excavation and intersection
随机推荐
vip股票账户在手机开通安全吗?
Neo4j application
Use of [golang learning notes] package
Can Verilog of synthetizable be integrated
Taoying collects goods in batches. How to save the babies that have not been uploaded and then import them later
小说里的编程 【连载之十八】元宇宙里月亮弯弯
torchvision.datasets.ImageFolder前的数据整理及使用方法
Yuanqi Digitalization: existing mode or open source innovation Lixia action
How ZK solves the problem of cerebral fissure
海外资深玩家的投资建议(2) 2021-05-03
QT set cache and compile output path
Real time monitoring of MySQL database changes_ Synchronize data_ Learn about canal_--- Canal work notes 001
Taobao assistant is disabled. What is the reason for using the big Taoying import data package to upload the baby prompt "the main image is required and cannot be empty"? How to solve it?
Still worrying about xshell cracking, try tabby
Leetcode high frequency question 62. different paths: how many paths does the robot have from the upper left corner to the lower right corner? Pure probability permutation and combination problem, not
10道面试基础笔试题,你能对几题?
【AcWing】周赛
软件测试工作内容太简单怎么办?
Array - 704. Binary search
[mathematical modeling summer training] location of distribution center