Java Concurrent Programming (medium): JMM, CAS, Volatile

4, Shared model memory 1. Java Memory Model (JMM) JMM documentation 5, Lock free of shared model In this chapter, we will implement concurrency control through non blocking optimistic locks 1. Solving thread safety problems without locks The following code solves the thread safety problem through synchronized. public class Code_04_Unsafe ...

Added by sushiX on Sun, 02 Jan 2022 23:28:25 +0200

Executor and Thread Pool

Definition Threads are heavy objects and should be avoided from being created and destroyed frequently. class XXXPool{ // Getting pooled resources XXX acquire() { } // Release pooled resources void release(XXX x){ } } Thread pool is a producer-consumer mode //A design method for pooling resources in a general sense class Th ...

Added by cyberplasma on Sun, 02 Jan 2022 21:39:14 +0200

Are concurrent programming synchronized variables thread safe

  catalogue Thread safety Single thread operation variable Multiple threads are read-only to variables or variables do not belong to shared resources Thread unsafe condition Multithreading can read and write variables A subclass overrides a parent class method to perform an unknown operation Variables: normal member variables, stati ...

Added by goleztrol on Fri, 31 Dec 2021 21:58:29 +0200

ConsumeQueue of RocketMQ storage

1, Function overview As an important part of RocketMQ storage implementation, ConsumeQueue provides the index function of message storage in each Queue under each Topic. In other words, each Queue under each Topic will have a ConsumeQueue to save the messages under the Queue in the CommitLog location. Like CommitLog, ConsumeQueue is implemente ...

Added by Nandini on Fri, 31 Dec 2021 21:42:04 +0200

java and contracting - learn AQS through ReentrantLock

Learn AQS with ReentrantLock java and contract( java.util.concurrent) is a powerful and extensible tool class for concurrency management provided by jdk. The main source code author is Doug lea (Doug Lee), a well-known concurrency programming master. The strong expansibility of the whole juc and the essence of concurrent programming thought ...

Added by DeeDee2010 on Mon, 27 Dec 2021 10:01:09 +0200

Multithreading --- explain in detail the use of various locks and locks

1. synchronized Refer to the article below for details https://blog.csdn.net/A_Java_Dog/article/details/118679431 synchronized(Object) Object cannot be string, integer or long, because strings are ultimately based on the data in a string constant pool. Thread synchronization synchronized The lock is the object, not the ...

Added by --ss-- on Mon, 27 Dec 2021 09:23:35 +0200

JAVA Concurrent Programming -- thread waiting wake-up mechanism and LockSupport

1. Overview of thread waiting wake-up mechanism2. The wait and notify methods in the object class implement thread waiting and wake-up3. The await post signal method in the condition interface realizes thread waiting and wake-up4. Restrictions on the use of object and Condition5. Introduction to locksupport class6. park wait and unpark wake-up ...

Added by maxsslade on Sun, 26 Dec 2021 18:31:49 +0200

Concurrent programming - processes and threads

Processes and threads process The program consists of instructions and data, but to run these instructions and read and write the data, you must load the instructions to the CPU and the data to the memory. Disk, network and other equipment are also needed in the process of instruction operation. Processes are used to load instructions, manage m ...

Added by NoPHPPhD on Sun, 26 Dec 2021 10:14:17 +0200

Talking about volatile in Java

Memory visibility Volatile is a lightweight synchronization mechanism provided by Java. It also plays an important role in concurrent programming. Compared with synchronized (usually called heavyweight lock), volatile is more lightweight. Compared with the huge overhead brought by using synchronized, if volatile can be used properly and reason ...

Added by gassaz on Fri, 24 Dec 2021 12:16:05 +0200

2021 latest Java Concurrent Programming interview questions

Writing high-quality concurrent code is a very difficult task. Since the first version, the Java language has built-in support for multithreading, which was great in those years. However, when we have a deeper understanding and more practice of concurrent programming, we have more schemes and better choices to realize concurrent programming. Th ...

Added by lc on Fri, 24 Dec 2021 11:01:33 +0200