当前位置:网站首页>[multi thread performance tuning] multi thread lock optimization (Part 1): optimization method of synchronized synchronization lock
[multi thread performance tuning] multi thread lock optimization (Part 1): optimization method of synchronized synchronization lock
2022-06-24 20:30:00 【SugarPPig】
JVM stay JDK1.6 A hierarchical locking mechanism is introduced to optimize Synchronized, When a thread acquires a lock , First, the object lock will become a biased lock , This is to optimize the switching between user state and kernel state caused by repeated acquisition of the same thread ; Secondly, if there are multiple threads competing for lock resources , Locks will be upgraded to lightweight locks , It is suitable for holding a lock for a short time , And there is a scene of alternating switching in locking ; The biased lock also uses a spin lock to avoid frequent switching between the thread user state and the kernel state , The system performance is greatly improved ; But if the lock competition is too fierce , Then the synchronization lock will be upgraded to a heavyweight lock .
Reduce lock competition , It's optimization Synchronized The key to synchronization lock .
- Try to make Synchronized Synchronization lock is in lightweight lock or deflection lock , Improve Synchronized Synchronization lock performance ;
- Reduce lock granularity To reduce lock competition is also one of the most commonly used optimization methods ;
- adopt Reduce lock holding time To improve the Synchronized The success rate of synchronous lock to acquire lock resource when spinning , avoid Synchronized The synchronization lock is upgraded to a heavyweight lock .
边栏推荐
- 年轻人捧红的做饭生意经:博主忙卖课带货,机构月入百万
- Camera rental management system based on qt+mysql
- CVPR 2022 remembers Sun Jian! Tongji and Ali won the best student thesis award, and hekaiming was shortlisted
- Confirm whether the host is a large terminal or a small terminal
- Difference between map and object
- Anti epidemic through science and technology: white paper on network insight and practice of operators | cloud sharing library No.20 recommendation
- lol手游之任务进度条精准计算
- Sequential stack traversal binary tree
- Huawei cloud modelarts has ranked first in China's machine learning public cloud service market for the fourth time!
- Otaku can't save yuan universe
猜你喜欢

Teach you how to cancel computer hibernation

Internet of things? Come and see Arduino on the cloud

宅男救不了元宇宙

Information theory of popular science Shannon

Bytebase joins Alibaba cloud polardb open source database community

Dongyuhui is not enough to bring goods to "rescue" live broadcast

What about the Golden Angel of thunder one? Golden Angel mission details

Redis installation of CentOS system under Linux, adding, querying, deleting, and querying all keys

2022年最新四川建筑八大员(电气施工员)模拟题库及答案

Making startup U disk -- Chinese cabbage U disk startup disk making tool V5.1
随机推荐
Wait for the victory of the party! After mining ebb tide, graphics card prices plummeted across the board
Open programmable infrastructure (OPI) project, redefining dpu/ipu
苹果不差钱,但做内容“没底气”
Making startup U disk -- Chinese cabbage U disk startup disk making tool V5.1
The name of the button in the Siyuan notes toolbar has changed to undefined. Has anyone ever encountered it?
Q1: error in JMeter filename must not be null or empty
16个优秀业务流程管理工具
科技抗疫: 运营商网络洞察和实践白皮书 | 云享书库NO.20推荐
Todesk remote control, detailed introduction and tutorial
基于QT+MySQL的相机租赁管理系统
Otaku can't save yuan universe
Microsoft Office Excel 2013 2016 graphic tutorial on how to enable macro function
基于SSM的物料管理系统(源码+文档+数据库)
IP address to integer
思源笔记工具栏中的按钮名称变成了 undefined,有人遇到过吗?
The latest simulated question bank and answers of the eight members (Electrical constructors) of Sichuan architecture in 2022
Stackoverflow 年度报告 2022:开发者最喜爱的数据库是什么?
gateway
Error in Android connection database query statement
Dx12 engine development course progress - where does this course go