java multithreaded programming -- various locks -- exclusive lock VS shared lock

reference resources: https://tech.meituan.com/2018/11/15/java-lock.html https://www.cnblogs.com/jyroy/p/11365935.html Exclusive lock and shared lock are the same concept. Let's first introduce the specific concepts, and then introduce the exclusive lock and shared lock through the source code of ReentrantLock and ReentrantReadWriteLock. Exclu ...

Posted by Mega on Mon, 06 Dec 2021 20:43:48 -0800

Thoroughly understand the unity async task feature

Is it 2017?? Using collaborative programs in Unity is usually a good way to solve some problems, but it also has some disadvantages: 1. The collaborator cannot return a value. This encourages programmers to create huge monolithic collaborations instead of writing them in many small ways. There are some alternative methods, such as passing th ...

Posted by pages on Mon, 06 Dec 2021 15:11:54 -0800

Multithreaded interview notes sorted by Zhang

The content may be sloppy, but they are all basic and important things that I think, and they also involve two multi-threaded interview questions Multithreading Process process Thread thread The program is static Process is an execution process of a program. It is a dynamic concept. A process will have multiple threads that do not affect ea ...

Posted by bivaughn on Sun, 05 Dec 2021 17:15:15 -0800

JUC learning - blocking queue 1

6,PriorityBlockingQueue An unbounded blocking queue that supports prioritization. The elements entering the queue will be sorted according to priority. public class PriorityBlockingQueue<E> extends AbstractQueue<E> implements BlockingQueue<E>, java.io.Serializable The unbounded priority blocking queue uses an array to ...

Posted by paulnaj on Thu, 02 Dec 2021 13:51:32 -0800

Why doesn't Alibaba allow the use of Executors to create thread pools

Thread pool: common problems of business code In the program, we will use various pool optimization caches to create expensive objects, such as thread pool, connection pool and memory pool. Generally, some objects are created in advance and put into the pool. When they are used, they are directly taken out for use and returned for reuse. The n ...

Posted by SparkleD on Wed, 01 Dec 2021 14:46:09 -0800

JUC learning - atomic operation class

1, Atomic operation class in JUC 1. Introduction to atomic classes in JUC What is atomic operation? atomic means atom in Chinese. In chemistry, we know that atoms are the smallest unit of general matter and are inseparable in chemical reactions. Here, atomic means that an operation is non interruptible. Even when multiple threads execute to ...

Posted by damianjames on Wed, 01 Dec 2021 07:29:34 -0800

Usage demo of thread pool ThreadPoolExecutor

1. Example code: Runnable + ThreadPoolExecutor First create a Runnable Implementation class of interface (of course, it can also be Callable Interface. We also mentioned the area of the two above Don't MyRunnable.java import java.util.Date; public class MyRunnable implements Runnable { private String command; ...

Posted by sharal on Tue, 30 Nov 2021 13:22:58 -0800

java multithreaded programming -- thread pool

reference resources: https://blog.csdn.net/qq_27581243/article/details/86650682 https://www.cnblogs.com/zincredible/p/10984459.html Thread is a heavyweight resource. The creation, startup and destruction of threads consume system resources. At the same time, it is limited by system resources. The relationship between the number of threads and ...

Posted by yumico23 on Mon, 29 Nov 2021 17:18:16 -0800

Principle of thread pool and custom thread pool

Thread pool execution principle and custom thread pool Thread pool execution principle: Daily record (1) . advantages of using thread pool:      Application of pooling Technology: thread pool, database connection pool, http connection pool, etc.      The idea of pooling technology is mainly to reduce t ...

Posted by toodi4 on Fri, 26 Nov 2021 19:47:53 -0800

JMH quick start

Introduction to JMH JMH is a tool set dedicated to code micro benchmarking. JMH is developed by the team implementing Java virtual machine. Since the JVM has become more and more intelligent, it may be optimized to varying degrees in the compilation stage, class loading stage and running stage of java files, so the code written by developers ...

Posted by Uranium-235 on Fri, 26 Nov 2021 13:16:52 -0800