Click on “Yao Dao Source Code” above and select “Set as Star” Does she care about the front wave or the back wave? A wave that can wave is a good wave! Update articles every day at 10:33, lose a million bits of hair every day… Source code boutique column Original | Java 2021 Super […]
Tag: lock
Linux blocking and non-blocking
1. Introduction to blocking and non-blocking block non-blocking fd = open(“/dev/xxx_dev”, O_RDWR); //open file in blocking mode fd = open(“/dev/xxx_dev”, O_RDWR | O_NONBLOCK); /* open in non-blocking mode */ 2. Waiting queue 1. Waiting for the head of the queue The biggest advantage of blocking access is that when the device file is inoperable, the […]
Byte Two: Tell me about your understanding of MySQL locking?
I saw in the group yesterday that everyone was discussing a MySQL lock issue, which is to execute the select … for update statement. If the query condition does not have an index field, should I add a “row lock” or a “table lock”? If you have done this experiment, you will find that when […]
SpringBoot integrates Redis, and understanding of cache penetration, cache avalanche, cache breakdown, how to add locks to solve the problem of cache breakdown? How to add distributed locks in distributed cases
Article directory 1. Steps 2. Specific process 1. Introduce pom dependencies 2. Modify the configuration file 3. Unit testing 4. Test results 3. Redis running status 4. Practical application in the project 5. Locking solves the problem of cache breakdown Code one (there is a problem) Code two (problem solving) 6. New questions 7. Distributed […]
Using a database to implement a local blocking queue
I learned the technology when I was doing development at Huawei. I was doing content review in the content management team and found that they used local queues. At that time, I asked the project manager of the company why they didn’t use mq. His answer was “One application can only use 5 Queues, we […]
ReentrantLock source code analysis
Foreword Note: The source code of this article comes from JDK11 ReentrantLock is a reentrant lock in Java, which can be used to replace the traditional synchronized keyword for thread synchronization. Here are some comparisons with the synchronized keyword: name implementation reentrancy interruption fairness Does it support timeout Release lock ReentrantLock Java API level , […]
Class variables, class methods, code blocks, abstract classes, interfaces, and inner classes
After learning about encapsulation, inheritance, and polymorphism in object-oriented programming, I recently came into contact with several new knowledge points. Sort it out here, help yourself to review, and also record my learning experience. 1. Class variables and class methods Instance objects of the same class only share a template prototype, and do not share […]
Analysis of ReentrantLock lock and unlock
Analysis of the principle of ReentrantLock Speaking of ReentrantLock, we all know that it is a reentrant mutex based on AQS (AbstractQueuedSynchronizer). If we want to analyze ReentrantLock, we have to start with AbstractQueuedSynchronizer. Analysis of AbstractQueuedSynchronizer AbstractQueuedSynchronizer has an internal class Node, and the underlying layer maintains a doubly linked list to form a […]
Redis distributed lock design ideas + code demo implementation
Design ideas of redis distributed lock acquire lock Use the Redis setnx command to try to acquire the lock. The setnx command can set the value of the key to the specified string if the key does not exist, and do nothing if the key already exists. Therefore, we can set the key of the […]
13. Row lock range_lock analysis_a bit complicated
Directory 1 premise 1.1 Knowledge reserve 1.2 Related background of the lock: 1.3 What are the row lock granularities? 1.4 Locking rules 1.5 Index in range query 1.4 Data preparation 2. Case 1: Equivalence query gap lock 2.1 Effect 2.2 Principle 3. Case 2: non-unique index equivalent lock 3.1 Effect 3.2 Description 4. Case 2: […]