Use of wait/notify and J.U.C Condition in synchronized thread communication and source code analysis

I remember there was a classic interview question: how to output from 1 to 100 in sequence with multiple threads? The last chapter talked about the use and principle analysis of locks in Java. The above interview questions should be handy This chapter mainly talks about the realization of production and consumption queue and Condition source c ...

Posted on Mon, 06 Dec 2021 23:08:14 -0500 by GoodWill

JUC learning - deep analysis of thread pool executor

1, Understanding of ThreadPoolExecutor The core implementation class of thread pool in Java is ThreadPoolExecutor. This chapter analyzes the core design and implementation of java thread pool based on the source code of JDK 1.8. Let's first look at the UML class diagram of ThreadPoolExecutor to understand the inheritance relationship of Thread ...

Posted on Sun, 05 Dec 2021 08:11:02 -0500 by dagee

Alibaba specification: the effect will be better if you manually create a thread pool. The solution is to manually create a thread pool ThreadPoolExecutor

Create thread pool manually When using Executors to create threads, Alibaba specification proposes to manually create thread pools, which will have a better effect. Using ThreadPoolExecutor to create a thread pool can avoid the risk of resource exhaustion (OOM) Constructor for ThreadPoolExecutor public ThreadPoolExecutor(int corePoolSize, ...

Posted on Sun, 05 Dec 2021 00:24:05 -0500 by tony-kidsdirect

Learning notes of C + + standard library - STL - concurrency - start thread

1, Advanced interfaces async() and Future async() provides an interface to make a caller object a separate thread. class future allows you to wait for the thread to end and get its results. 1. Instance Consider the following: func1() + func2() In a single thread, the overall processing time is the time spent by func1() plus the time s ...

Posted on Fri, 03 Dec 2021 15:57:31 -0500 by woza_uk

On four thread pools

Transferred from: Micro reading (www.weidianyuedu.com) Micro reading - complete collection of model articles - a website for free learning knowledge First, let's take a look at the code for obtaining four thread pools: ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10); ExecutorService cachedThreadPool = Executors.ne ...

Posted on Wed, 01 Dec 2021 11:45:38 -0500 by mattonline

Set up MPI parallel computing environment and calculate pi value [windows and Ubuntu]

Build MPI parallel computing environment, calculate pi value by using the formula for calculating pi, and use the number of multi threads n respectively Calculation results of 100, 1000 and 10000. The following is the analysis of the specific installation process and experimental results, analyzing the impact of n value on pi accuracy ...

Posted on Wed, 01 Dec 2021 03:44:30 -0500 by Orkan

[analysis of process, thread and fiber]

Process, thread, fiber: Concept: Process: a running program Thread: an execution queue in a running program. A process has multiple threads Fiber: generally refers to threads in threads; The kernel space is called when the thread starts, and the user space is called when the fiber starts. Switching between threads is heavy and consumes mor ...

Posted on Tue, 30 Nov 2021 05:16:32 -0500 by jds580s

Mutex of C + + multithread learning thread synchronization

preface Last article C + + multithreading learning (I) thread creation and management We have a preliminary understanding of the concept of thread and the process that has been proposed with thread, and the significance and difference between them. An example is given at the end of the article. I initially learned how to create multithreading ...

Posted on Tue, 30 Nov 2021 00:30:02 -0500 by agmorgan

AQS principle and ReentrantLock source code analysis

The full name of AQS is AbstractQueuedSynchronizer, that is, abstract queue synchronizer. This class is under the java.util.concurrent.locks package. AQS is a framework used to build locks and synchronizers. Using AQS can easily and efficiently construct a large number of synchronizers widely used, such as ReentrantLock and Semaphore, an ...

Posted on Sun, 28 Nov 2021 08:03:28 -0500 by edawg

[muduo reading notes] Chapter 1 - smart pointer

The whole content of this article comes from the "Linux multithreaded server programming using muduo network library" written by Mr. Chen Shuo. This is a personal reading note This paper discusses multithreading safety, and introduces mutex, the function and usage of smart pointer by gradually rewriting the multithreaded version of ob ...

Posted on Sat, 27 Nov 2021 14:52:08 -0500 by dabigchz