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

边栏推荐
- How to realize the bottom layer of read-write lock in go question bank 16
- indexof和includes的区别
- Openai video pre training (VPT): action learning based on watching unmarked online videos
- 寶,運維100+服務器很頭疼怎麼辦?用行雲管家!
- 数商云:从规划到落地,五矿集团如何快速构建数字化发展新格局?
- Summary of cases of players' disconnection and reconnection in Huawei online battle service
- AppGallery Connect场景化开发实战—图片存储分享
- Appgallery connect scenario development practice - image storage and sharing
- PostgreSQL varchar[] array type operation
- AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award
猜你喜欢

机械设备行业数字化供应链集采平台解决方案:优化资源配置,实现降本增效

Lumiprobe 细胞成像研究丨PKH26细胞膜标记试剂盒

Huawei cloud experts explain the new features of gaussdb (for MySQL)

有关 M91 快速霍尔测量仪的更多信息

线程的并行、并发、生命周期
![[to.Net] C set class source code analysis](/img/59/4c7b910bc6505e5f81015ce80812fc.png)
[to.Net] C set class source code analysis

Lake Shore—OptiMag 超导磁体系统 — OM 系列

CDGA|从事通信行业,那你应该考个数据管理证书

Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?

Dom4J解析XML、Xpath检索XML
随机推荐
Dlib+opencv library for fatigue detection
Bao, que se passe - t - il si le serveur 100 + O & M a mal à la tête? Utilisez le majordome xingyun!
Manufacturing SRM management system supplier all-round closed-loop management, to achieve procurement sourcing and process efficient collaboration
Contos 7 搭建sftp之创建用户、用户组以及删除用户
Dlib+Opencv库实现疲劳检测
241. Different Ways to Add Parentheses
Lean thinking: source, pillar, landing. I understand it after reading this article
Lake Shore 连续流动低温恒温器传输线
Go language self-study series | go language data type
pickle.load报错【AttributeError: Can‘t get attribute ‘Vocabulary‘ on <module ‘__main__‘】
Openai video pre training (VPT): action learning based on watching unmarked online videos
Viewing the whole ecology of Tiktok from a macro perspective
Cache problems after app release
AppGallery Connect场景化开发实战—图片存储分享
Lake Shore低温恒温器的氦气传输线
Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
11. Users, groups, and permissions (1)
SuperOptiMag 超导磁体系统 — SOM、SOM2 系列
助力数字经济发展,夯实数字人才底座—数字人才大赛在昆成功举办
云服务器ECS夏日省钱秘籍,这次@老用户快来领走