当前位置:网站首页>[interview: concurrency 14: multithreading: monitor concept]
[interview: concurrency 14: multithreading: monitor concept]
2022-07-18 05:21:00 【I cream】
【 interview : Concurrent articles 14: Multithreading : Monitor Concept 】
00. Preface
If you have any questions, please point out , thank .
01.Java Object head
With 32 For example, bit virtual machine
Common object
| Object Header(64bit) |
|---|
| Mark Word(32bits) | Klass Word(32bits) |
|---|
explain
The object contains a header :Mark Word(32bits)Klass Word(32bits)
Klass Word(32bits): It's a pointer It points to the class it belongs to
Mark Word(32bits): Here's the explanation
Array objects
| Object Header(64bit) |
|---|
| Mark Word(32bits) | Klass Word(32bits) | array length(32bits) |
|---|
There is one more array object array length(32bits) Used to specify the length of the array
Mark Word structure
| Mark Wor(32bits) | Locked state | State |
|---|---|---|
| hashcode:25 age:4 biased_lock:0 | 01 | Normal |
| thread:23 epoch:2 age:4 biased_lock:1 | 01 | Biased |
| ptr_to_lock_record:30 | 00 | Lightweight Locked |
| ptr_to_heavyweight_montior:30 | 10 | Heavyweight Locked |
| 11 | Marked for GC |
02.Monitor
Introduce
Monitor Translated as monitor or tube side , every last java Objects can be associated with a Monitor object , If you use synchronized Lock the object ( Heavyweight lock ) after , Change object header MarkWord Is set to point to Monitor Object pointer
Picture explanation

We can see that this time is Two threads have not yet executed Critical area code block , So at this time obj Object's MarkWord For the above MarkWord In state normal state .

after Thread-1 First, the critical area code is executed , So at this time obj Object's MarkWord The state of locking in the middle becomes 10 The state becomes Heavyweight Locked, Now? obj The head of the object MarkWord Is set to point to Monitor The pointer to , And at this point Monitor Under surveillance Thread-1.

then Thread-2 To get the lock Found to have been occupied , Then it is placed in the blocking list EntryList.
边栏推荐
- E-commerce platform background management system --- > system detailed design (user management module)
- 微信小程序从入门到学会第十天-------小程序的其它操作
- JMM内存模型
- datatable删除行
- FreeModbus 在 STM32F1 平台的移植和解析
- Mobile Robotics (I) fundamentals of Mathematics
- 曲线上点的曲率半径计算
- CRMEB Pro v1.4,让用户体验更出彩!
- Core examination site for information system project managers (XI) two key technologies and architectures of the Internet of things
- Cool dog music interface is amazingly open
猜你喜欢

阿里云架构师马颂:云上高性能计算助力基因测序

Salesforce Dynamic Dashboard动态报表、限制与解决方案

Redis05: redis transactions

Alibaba cloud e-mapreduce geek competition is open for registration. Hundreds of thousands of bonuses are waiting for you to challenge

Proxy settings such as nifi listsftp

1 start.s分析

Salesforce中解析合并字段Merge Fields

STM32F103 串口DMA + 空闲中断 实现不定长数据收发

C # write a GUI tool and decompile it

STM32F103 serial port +dma interrupt to realize data sending and receiving
随机推荐
蚂蚁隐私计算创新TEE技术获学术认可
Xiaobai challenges the first day of learning C language - the construction of the operating environment
Chess all in one
Information system project managers must recite the core examination sites (10) information system planning
If you don't want to step on those holes in SaaS, you must first understand the "SaaS architecture"
微信小程序从入门到学会第十天-------小程序的其它操作
STM32 IAP远程更新
E-commerce platform background management system -- > operation method description
Salesforce Dynamic Dashboard动态报表、限制与解决方案
在Salesforce中基于SAML 2.0搭建SSO并启用JIT User Provisioning(SF Orgs间 / SF Org与Experience Cloud间 / 其他IdP)
移动机器人学(一) 数学基础
Wechat applet from getting started to learning the ninth day -- system operation of applet
Information system project manager 10 days before the exam limit sprint + answer (7)
Core examination sites for information system project managers (VI) layering of OSI protocol, mapping + real questions
E-commerce platform background management system --- > system detailed design (user management module)
CRMEB Pro v1.4,让用户体验更出彩!
Redis05: redis transactions
INSUFFICIENT_ACCESS_ON_ CROSS_REFERENCE_ENTITY APEX / SALESFORCE
Nifi cluster construction and necessary related configurations
Information system project manager 10 days before the exam limit sprint + answer (6): project procurement management and contract management