当前位置:网站首页>Parallelism, concurrency and life cycle of threads
Parallelism, concurrency and life cycle of threads
2022-07-01 19:25:00 【Gentle ~】
This article is only a simple record , For more professional content, it is recommended to read about threads in the operating system 、 Knowledge of processes .
Concurrency and parallelism
Running programs ( Software ) It's an independent process , Threads belong to processes , Multiple threads are actually concurrent and parallel .
Understanding of concurrency
1.CPU The number of simultaneous processing threads is limited ;
2.CPU Will poll for each thread of the system , because CPU The switching speed is very fast , It gives us the feeling that these threads are executing at the same time , This is concurrency .
Parallel understanding
At the same time , There are multiple threads being used at the same time CPU Process and execute .
Declaration cycle of thread
State of thread
That is, the process of thread from birth to death , And various states and state transitions in the middle , Understanding the state of threads is helpful to improve the understanding ability of concurrent programming .
Java State of thread
Java In all, it defines 6 States , It's defined in Thread The internal enumeration of the class .
public enum State {
NEW,
RUNNABLE,
BLOCKED,
WAITING,
TIMED_WAITING,
TERMINATED;
}
state | explain |
---|---|
NEW( newly build ) | Thread just created , But it didn't start |
Runnable( Can run ) | The thread has called start() wait for CPU Dispatch |
Blocked( The lock is blocked ) | The thread does not compete for the lock object when executing , Then the thread enters Blocked state |
Waiting( Wait indefinitely ) | A thread enters Waiting state , Another thread called notify perhaps notifyAll Method to wake up |
Timed Waiting( Time wait for ) | Same as waiting state , There are several methods that have timeout parameters , Call them and they will enter Timed Waiting state . Common methods with timeout parameters are Thread.sleep 、Object.wait |
Teminated( Terminated ) |
Knowledge Links :Java Thread communication
Thread 6 Mutual transformation of States
边栏推荐
- 华为联机对战服务玩家掉线重连案例总结
- Contos 7 set up SFTP to create users, user groups, and delete users
- Improve yolov5 with gsconv+slim neck to maximize performance!
- [quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
- 【Go ~ 0到1 】 第五天 7月1 类型别名,自定义类型,接口,包与初始化函数
- Witness the times! "The future of Renji collaboration has come" 2022 Hongji ecological partnership conference opens live broadcast reservation
- Lake Shore 连续流动低温恒温器传输线
- Lumiprobe 自由基分析丨H2DCFDA说明书
- 白盒加密技术浅理解
- 见证时代!“人玑协同 未来已来”2022弘玑生态伙伴大会开启直播预约
猜你喜欢
C端梦难做,科大讯飞靠什么撑起10亿用户目标?
Nacos configuration file publishing failed, please check whether the parameters are correct solution
June issue | antdb database participated in the preparation of the "Database Development Research Report" and appeared on the list of information technology and entrepreneurship industries
案例分享:QinQ基本组网配置
Lake Shore—CRX-EM-HF 型低温探针台
Learn MySQL from scratch - database and data table operations
Lumiprobe 活性染料丨吲哚菁绿说明书
Dlib+Opencv库实现疲劳检测
The market value evaporated by 74billion yuan, and the big man turned and entered the prefabricated vegetables
Solution of intelligent supply chain management platform in aquatic industry: support the digitalization of enterprise supply chain and improve enterprise management efficiency
随机推荐
How to operate technology related we media well?
The difference between indexof and includes
Today, with the popularity of micro services, how does service mesh exist?
The intelligent epidemic prevention system provides safety guarantee for the resumption of work and production at the construction site
MATLAB中subplot函数的使用
实现一个Prometheus exporter
[to.Net] C set class source code analysis
Summary of cases of players' disconnection and reconnection in Huawei online battle service
Supervarimag superconducting magnet system SVM series
Team up to learn! 14 days of Hongmeng equipment development "learning, practicing and testing" practical camp, free of charge!
记一次 .NET 差旅管理后台 CPU 爆高分析
精益思想:来源,支柱,落地。看了这篇文章就懂了
Altair HyperWorks 2022 software installation package and installation tutorial
白盒加密技术浅理解
混沌工程平台 ChaosBlade-Box 新版重磅发布
Shell array
3. "Create your own NFT collections and publish a Web3 application to show them" cast NFT locally
Example explanation: move graph explorer to jupyterlab
Implement a Prometheus exporter
Prices of Apple products rose across the board in Japan, with iphone13 up 19%