Java JUC LinkedBlockingQueue parsing
Blocking queue LinkedBlockingQueueintroduceThe previous article introduces the non blocking queue concurrent linkedqueue implemented by CAS algorithm, and this article introduces the blocking queue LinkedBlockingQueue implemented by exclusive lock.The class diagram shows that the LinkedBlockingQueue is also implemented using a one-way linked li ...
Added by chadowch on Wed, 26 Jan 2022 15:15:34 +0200
java read / write lock ReentrantReadWriteLock
summary
When we introduced AQS, they were basically exclusive locks (mutual exclusion locks). These locks only allowed one thread to access at the same time, while read-write locks allowed multiple threads to access at the same time.
When the read operation is much higher than the write operation, the read-write lock is used to make the read- ...
Added by chowwiie on Wed, 26 Jan 2022 10:40:24 +0200
JUC simple learning notes
juc concurrent programming
Introduction to juc
java.util .concurrent, Java and contract
Written examination questions
Handwriting singleton modeHandwritten bubble sortingProducer consumer variants
Process / thread review
What is a process / thread?
**Process: * * process is a running activity of a program with certain independent fun ...
Added by ToeBee on Tue, 25 Jan 2022 15:04:49 +0200
Java JUC ReentrantLock parsing
Exclusive lock ReentrantLock principleintroduceReentrantLock is a reentrant exclusive lock. At the same time, only one thread can acquire the lock. Other threads acquiring the lock will be blocked and put into the AQS blocking queue of the lock.It has the same basic behavior and semantics as synchronized, but ReentrantLock is more flexible and ...
Added by isedeasy on Mon, 24 Jan 2022 07:53:41 +0200
Source code analysis of ConcurrentHashMap
6. Membership method
6.1 some auxiliary methods
spread(int h) method
This method is used to calculate the hash value of Node nodes. When calculating the hash value, the high order of h is also used to make the Hash list more scattered.
// 0x7fffffff is converted to binary, which is 11111111111111111111111111111111111111111111111111111111111 ...
Added by Skara on Sat, 22 Jan 2022 22:12:06 +0200
List collection thread unsafe & solution
1, ArrayList is not secure
1. Fault phenomenon
public class NotSafeDemo {
public static void main(String[] args) {
List<String> list = new ArrayList();
for (int i = 0; i < 30; i++) {
//Multiple threads modify the collection at the same time
new Thread(() -> {
//Add conte ...
Added by pliant on Fri, 21 Jan 2022 20:32:44 +0200
Multithreaded ThreadLocal source code
Reference articles
1. What is ThreadLocal? And its general purpose
(1) Definition (2) function
ThreadLocal is used to provide local variables for internal use in threads. In other words, it uses a set of mechanisms to ensure that you create a new variable ThreadLocal. In a thread, set the ThreadLocal variable to an instance a of type A th ...
Added by ClosetGeek on Fri, 21 Jan 2022 10:30:13 +0200
AQS analysis of Java JUC Abstract synchronization queue
AQS resolution of abstract synchronization queueAQS - underlying support for locksAbstractQueuedSynchronizer Abstract synchronization queue is called AQS for short. It is the basic component to implement the synchronizer, and the underlying lock in the contract is implemented using AQS. Let's take a look at the class diagram structure of AQS.It ...
Added by budder on Fri, 21 Jan 2022 01:02:47 +0200
Inter thread communication - Synchronized thread communication & false wake-up
1, Inter thread communication
There are two models of inter thread communication: shared memory {and} message passing. The following methods are implemented based on these two models.
When the thread start() method is called, it is scheduled by the operating system, and the execution order is not fixed.
If you want threads to execute in the req ...
Added by php noob on Wed, 19 Jan 2022 19:18:10 +0200
Four common concurrent tool classes in JUC
JUC is Java util. Concurrent package, commonly known as JUC, contains some things to solve concurrency problems.This package is located under the rt.jar package under javaFour common concurrent tool classes:CountDownLatchCountDownLatch is a class I use more at present. A count will be given during the initialization of CountDownLatch, and then ...
Added by NCC1701 on Tue, 18 Jan 2022 03:07:06 +0200