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

边栏推荐
- XML语法、约束
- Witness the times! "The future of Renji collaboration has come" 2022 Hongji ecological partnership conference opens live broadcast reservation
- [live broadcast appointment] database obcp certification comprehensive upgrade open class
- How to realize the applet in its own app to realize continuous live broadcast
- Lumiprobe phosphide hexaethylene phosphide specification
- Shell array
- 云服务器ECS夏日省钱秘籍,这次@老用户快来领走
- Contos 7 搭建sftp之创建用户、用户组以及删除用户
- Lake Shore M91快速霍尔测量仪
- Dlib+Opencv库实现疲劳检测
猜你喜欢

【pytorch记录】自动混合精度训练 torch.cuda.amp

生鲜行业B2B电商平台解决方案,提高企业交易流程标准化和透明度

MySQL common graphics management tools | dark horse programmers

赋能「新型中国企业」,SAP Process Automation 落地中国

Docker deploy mysql8.0

Lake Shore M91快速霍尔测量仪

pickle.load报错【AttributeError: Can‘t get attribute ‘Vocabulary‘ on <module ‘__main__‘】

The best landing practice of cave state in an Internet ⽹⾦ financial technology enterprise

Prices of Apple products rose across the board in Japan, with iphone13 up 19%

有关 M91 快速霍尔测量仪的更多信息
随机推荐
PostgreSQL varchar[] array type operation
实现一个Prometheus exporter
The former 4A executives engaged in agent operation and won an IPO
Learning notes - steps of JDBC connection database operation
Clean up system cache and free memory under Linux
水产行业智能供应链管理平台解决方案:支撑企业供应链数字化,提升企业管理效益
AppGallery Connect场景化开发实战—图片存储分享
前4A高管搞代运营,拿下一个IPO
[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
Lumiprobe free radical analysis h2dcfda instructions
苹果产品在日本全面涨价,iPhone13涨19%
C-end dream is difficult to achieve. What does iFLYTEK rely on to support the goal of 1billion users?
Lumiprobe 亚磷酰胺丨六甘醇亚磷酰胺说明书
论文阅读【Discriminative Latent Semantic Graph for Video Captioning】
How to realize the bottom layer of read-write lock in go question bank 16
【森城市】GIS数据漫谈(一)
见证时代!“人玑协同 未来已来”2022弘玑生态伙伴大会开启直播预约
Contos 7 搭建sftp之创建用户、用户组以及删除用户
Write it down once Net travel management background CPU Explosion Analysis
Altair HyperWorks 2022 software installation package and installation tutorial