当前位置:网站首页>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

边栏推荐
- Enabling "new Chinese enterprises", SAP process automation landing in China
- 【直播预约】数据库OBCP认证全面升级公开课
- nacos配置文件发布失败,请检查参数是否正确的解决方案
- Solidity - 合约结构 - 错误(error)- ^0.8.4版本新增
- Learning notes - steps of JDBC connection database operation
- Learn MySQL from scratch - database and data table operations
- Games202 operation 0 - environment building process & solving problems encountered
- Contos 7 set up SFTP to create users, user groups, and delete users
- Three simple methods of ES6 array de duplication
- Lumiprobe 自由基分析丨H2DCFDA说明书
猜你喜欢

M91快速霍尔测量仪—在更短的时间内进行更好的测量

Manufacturing SRM management system supplier all-round closed-loop management, to achieve procurement sourcing and process efficient collaboration

线程的并行、并发、生命周期

Enabling "new Chinese enterprises", SAP process automation landing in China

The intelligent epidemic prevention system provides safety guarantee for the resumption of work and production at the construction site

Viewing technological changes through Huawei Corps (VI): smart highway

Openai video pre training (VPT): action learning based on watching unmarked online videos

云服务器ECS夏日省钱秘籍,这次@老用户快来领走

前4A高管搞代运营,拿下一个IPO

【森城市】GIS数据漫谈(一)
随机推荐
Gameframework eating guide
AppGallery Connect场景化开发实战—图片存储分享
Graduation summary
[AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?
论文阅读【Discriminative Latent Semantic Graph for Video Captioning】
Solution of digital supply chain centralized purchase platform in mechanical equipment industry: optimize resource allocation and realize cost reduction and efficiency increase
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
Cache problems after app release
Prices of Apple products rose across the board in Japan, with iphone13 up 19%
ECS summer money saving secret, this time @ old users come and take it away
Today, with the popularity of micro services, how does service mesh exist?
Solidity - 算术运算的截断模式(unchecked)与检查模式(checked)- 0.8.0新特性
Redis 实现限流的三种方式
Lake Shore continuous flow cryostat transmission line
洞态在某互联⽹⾦融科技企业的最佳落地实践
Cdga | if you are engaged in the communication industry, you should get a data management certificate
小红书上的爱情买卖
Huawei game failed to initialize init with error code 907135000
Lumiprobe 细胞成像研究丨PKH26细胞膜标记试剂盒
【pytorch记录】自动混合精度训练 torch.cuda.amp