CountDownLatch&Semaphore&CyclicBarrier&Executors of concurrent programming

1, Semaphore Semaphore definition Semaphore literally means semaphore. Its function is to control the number of threads accessing specific resources. The bottom layer depends on the State of AQS. It is a tool class commonly used in production. Common methods of Semaphore Construction method public Semaphore(int permits) public Semaphore(in ...

Added by ca87 on Wed, 02 Feb 2022 14:12:53 +0200

[concurrent programming] detailed explanation of synchronized bias lock, lightweight lock and heavyweight lock

Lock status corresponding to memory layout Let's start with the conclusion of the change of lock state Bias lock Bias lock is an optimization method for locking operation. In most cases, locks not only do not have multi-threaded competition, but are always obtained by the same thread many times. Therefore, biased locks are introduced to elim ...

Added by dink87522 on Tue, 01 Feb 2022 22:58:36 +0200

Proficient in concurrent programming from semare to Semaphore

What is Semaphore? Semaphore, commonly known as semaphore, is the implementation of the primitive of PV operation in the operating system in java. Implementation based on AbstractQueuedSynchronizer! Semaphore is very powerful. Semaphores with a size of 1 are similar to mutually exclusive locks, which can be achieved by only one thread acquirin ...

Added by ClosetGeek on Tue, 01 Feb 2022 19:09:12 +0200

5 minutes to understand - fair lock, unfair lock, reentry lock, spin lock, read-write lock

Fair lock and unfair lock Fair lock It refers to that multiple threads acquire locks according to the order of applying for locks, and follow the principle of first come, first serve. Its implementation can use queues. Unfair lock The method of multiple threads acquiring locks is not in the order of applying for locks. The thread that ap ...

Added by balloontrader on Mon, 31 Jan 2022 12:53:02 +0200

[concurrent programming] understand various mechanisms of ReentrantLock lock easily

What is ReentrantLock? ReentrantLock is an application implementation based on AQS framework. It is a synchronization method of thread concurrent access in JDK. Its function is similar to synchronized. It is a mutual exclusion lock, which can ensure thread safety. Difference between ReentrantLock and synchronized synchronized is the lock imp ...

Added by cesarcesar on Sun, 30 Jan 2022 16:42:18 +0200

Fundamentals of Java multithreaded programming (day 18 of Java from self-study to employment)

Java learning record day 18 Since this slag is converted to Java at the front end, the selection of editor is directly used webstorm With the company idea Some of the following knowledge will be learned from the boss Liao Xuefeng's blog Learning objectives What is multithreading and how to use it? Learning content Java multithreadi ...

Added by Brink Kale on Sun, 30 Jan 2022 15:15:48 +0200

JUC study notes

1. What is JUC? java.util Toolkit 2. Process and thread Process and thread Process: the execution process of a program. It is a running activity of the program on a data set in the computer. It is the basic unit for resource allocation and scheduling of the system and the basis of the structure of the operating system. Narrow definit ...

Added by Arrow on Sun, 30 Jan 2022 00:05:35 +0200

Detailed explanation of CountDownLatch principle

introduce When you read this article, you need to understand the principle of AQS first, because this article does not involve the explanation of the internal principle of AQS. CountDownLatch is a synchronization assistant. When multiple threads execute tasks, we need to wait for the thread to complete the execution before executing the ...

Added by lasse48 on Sat, 29 Jan 2022 16:25:17 +0200

Source code analysis of AQS (AbstractQueuedSynchronizer)

What is AQS? In Lock, a synchronization queue AQS is used. Its full name is AbstractQueuedSynchronizer. It is a synchronization tool and the core component used by Lock to realize thread synchronization. java. util. Most of the tools in concurrent are implemented through AQS. The core idea of AQS is that if the requested shared resource is idl ...

Added by tcarnes on Sat, 29 Jan 2022 16:21:22 +0200

leetcode1195. Alternate print string (java implementation)

subject Original question connection leetcode1195 Title Description: Write a program that can output a string representing this number from 1 to n, but: If this number can be divided by 3, output "fizz".If this number can be divided by 5, output "buzz".If this number can be divided by 3 and 5 at the same time, output &quot ...

Added by non_zero on Sat, 29 Jan 2022 03:08:16 +0200