当前位置:网站首页>[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 .
边栏推荐
- 京东一面:Redis 如何实现库存扣减操作?如何防止商品被超卖?
- [cann document express issue 06] first knowledge of tbe DSL operator development
- OpenVINO2022 Dev Tools安装与使用
- How does the video platform import the old database into the new database?
- 物联网?快来看 Arduino 上云啦
- 微信小程序自定义tabBar
- 顺序表的基本操作
- 年轻人捧红的做饭生意经:博主忙卖课带货,机构月入百万
- The first public available pytorch version alphafold2 is reproduced, and Columbia University is open source openfold, with more than 1000 stars
- Maps are grouped according to the values of the passed in parameters (similar to database groupby)
猜你喜欢

The latest simulated question bank and answers of the eight members (Electrical constructors) of Sichuan architecture in 2022

字节、腾讯也下场,这门「月赚3000万」的生意有多香?

Teach you how to cancel computer hibernation

实现基于Socket自定义的redis简单客户端

顺序栈1.0版本

Install the custom module into the system and use find in the independent project_ Package found

Cooking business experience of young people: bloggers are busy selling classes and bringing goods, and the organization earns millions a month

Microsoft Office Excel 2013 2016 graphic tutorial on how to enable macro function

Leetcode(135)——分发糖果

JMeter environment deployment
随机推荐
物聯網?快來看 Arduino 上雲啦
情绪识别AI竟「心怀鬼胎」,微软决定封杀它!
unity实战之lol技能释放范围
Introduction: continuously update the self-study version of the learning manual for junior test development engineers
The AI for emotion recognition was "harbouring evil intentions", and Microsoft decided to block it!
宅男救不了元宇宙
Material management system based on SSM (source code + document + database)
Sequence stack version 1.0
[cann document express issue 05] let you know what operators are
Implement the redis simple client customized based on socket
The first public available pytorch version alphafold2 is reproduced, and Columbia University is open source openfold, with more than 1000 stars
Get to know the data structure of redis - hash
Docker deploy mysql5.7
What is CNN (convolutional neural network)
lol手游之任务进度条精准计算
Bytebase rejoint la communauté de base de données open source d'alicloud polardb
首个大众可用PyTorch版AlphaFold2复现,哥大开源OpenFold,star量破千
Apache+PHP+MySQL环境搭建超详细!!!
Sequential stack traversal binary tree
JMeter environment deployment