Concurrent programming synchronized

Concurrent programming synchronized What I said earlier As I said at the beginning, I want to sort out some learning documents of java Concurrent Programming. This is the third article: synchronized keyword. It mainly discusses the use of synchronized keywords, lock principle, lock reentry, dirty reading, lock upgrade and other issues. Welc ...

Posted by hykc on Wed, 09 Mar 2022 11:46:40 +0100

Talk about the Unsafe class in Java

1, Introduction to Unsafe class If you have seen the source code of JUC, I believe you will not be unfamiliar with the Unsafe class. The bottom core of the whole JUC is the Unsafe class. The Unsafe class is located in sun A class under misc package, which is a tool class (underlying c + + implementation) provided by jdk to directly access oper ...

Posted by juliston on Tue, 08 Mar 2022 03:18:42 +0100

Lock interface

catalogue 1.1 review synchronized 1.2 Lock interface 1.3 Lock method 1.4 difference between the two 1.1 review synchronized It is a keyword of Java. It is a kind of synchronous lock, which can modify an object, variable and method, To control this modified, sequential access, Multithreaded programming steps: First: create a resource class, at ...

Posted by roice on Mon, 07 Mar 2022 04:39:50 +0100

Basic knowledge of JUC (personal summary)

Statement: 1 ***               2. Because it is a personal summary, write the article with the most concise words               3. If there is any mistake or improper place, please point out I Front Foun ...

Posted by adrafa on Sat, 05 Mar 2022 02:19:50 +0100

Synchronization mechanism of 0 multithreaded threads

1. Background Example: create a window to sell tickets, and the total number of tickets is 100 Use the way to implement the Runnable interface * 1. Problem: in the process of selling tickets, there are duplicate tickets and wrong tickets -- > there are thread safety problems2. Cause of the problem: when a thread is operating the ticket ...

Posted by hardyvoje on Fri, 04 Mar 2022 23:41:42 +0100

Application and principle of ThreadPoolExecutor thread pool

1. Custom thread pool Thread is a kind of system resource. Every time it is created, it will consume some system resources. If a new thread is created for each task in a high concurrency scenario, it will occupy a lot of system space and even cause the problem of memory overflow. Moreover, the number of threads cannot be too large. If there ...

Posted by Hoangsta on Mon, 14 Feb 2022 02:04:24 +0100

CountDownLatch thread synchronization for Java Concurrent Programming learning

preface Scene description Briefly describe this step. Open three threads and call three different methods. Use the countdowncatch counter to wait for the completion of all three methods, and then merge the data Basic concepts introduce CountDownLatch is a synchronization tool class that allows one or more threads to wait until other t ...

Posted by davidjwest on Thu, 10 Feb 2022 08:00:51 +0100

Java JUC ThreadPoolExecutor parsing

Thread pool ThreadPoolExecutorintroduceThread pool mainly solves two problems: one is that thread pool can provide better performance when executing a large number of asynchronous tasks. When the thread pool is not used, a new thread is required to execute whenever a task needs to be executed. Frequent creation and destruction consume performan ...

Posted by gamblor01 on Thu, 10 Feb 2022 02:06:25 +0100

Addition and subtraction counters of JUC Toolkit

1. CountDownLatch CountDownLatch is called a subtraction counter. In practical application, according to the explanation of JDK document, there are two scenarios applicable. Usage 1: as a starting gun, one thread holds the starting gun and orders other threads to start at the same time Usage 2 is to observe the start or end time of all t ...

Posted by tomd79 on Tue, 08 Feb 2022 04:13:24 +0100

Source code analysis of AQS&ReentrantLock

There are two main methods to realize synchronization in Java: Synchronized and Lock. In the previous article, we introduced that Synchronized is an object Lock at the JVM level. Its implementation is based on the MESA management model, while Lock is implemented by Jdk. It is also based on the MESA management model. The core implementation of L ...

Posted by brownca on Thu, 27 Jan 2022 09:08:39 +0100