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

JUC learning - user threads and daemon threads

1, User thread and daemon thread 1. Guardian thread & understanding of user thread Daemon thread is a special thread that silently completes some systematic services in the background, such as garbage collection thread and JIT thread. The corresponding is the user thread, which can be understood as the working thread of the system. It wi ...

Posted on Thu, 25 Nov 2021 15:27:39 -0500 by ben2468

JUC study Chapter 8 J.U.C reentrant principle

Reentrant principle static final class NonfairSync extends Sync { // ... // Sync inherited method, easy to read, put here final boolean nonfairTryAcquire(int acquires) { final Thread current = Thread.currentThread(); int c = getState(); if (c == 0) { if (compareAndSetState(0, acquires)) { ...

Posted on Sat, 20 Nov 2021 00:24:56 -0500 by conspi

Understanding of CAS and some interview questions

CAS definition: The full name of CAS is compare and swap. It is a CPU concurrency primitive. Its function is to judge whether the value of a location in memory is the expected value. If so, it will be changed to a new value. This process is atomic. The CAS operation contains three operands: memory location (V), expected value (A), and new va ...

Posted on Tue, 02 Nov 2021 23:46:52 -0400 by wizkid

[concurrent programming] (learning notes - management of shared model) - part3

Concurrent programming - management of shared model-3 This article is a video guide 👉 Dark horse programmer - Concurrent Programming 1. Problems caused by sharing 1-1 Critical Section There is no problem for a program to run multiple threadsThe problem is that multiple threads access shared resources In fact, there is no problem for ...

Posted on Mon, 01 Nov 2021 19:53:16 -0400 by jainsy

BlockingQueue blocking queue

1. Queue + blocking queue          (1) Blocking queue, as its name implies, is a queue, and the role of a blocking queue in the data structure is roughly shown in the following figure:          When the blocking queue is empty, the operation of getting elements ...

Posted on Sun, 31 Oct 2021 08:29:52 -0400 by freelance84

Java -- JUC high concurrent programming, Fork/Join

11 Fork/Join 11.1 introduction to fork / join framework Fork/Join can split a large task into multiple subtasks for parallel processing, and finally merge the subtask results into the final calculation results for output. The Fork/Join framework does two things: Fork: break up a complex task and make it smallJoin: merge the results of the sp ...

Posted on Sat, 30 Oct 2021 23:16:35 -0400 by djKale

Concurrent programming from scratch - synchronization tool class

Concurrent programming from scratch (ten) - synchronization tool class 6 synchronization tools 6.1 Semaphore Semaphore, that is, semaphore, provides concurrent access control over the number of resources. Its code is very simple, as shown below: The function of the parameter method tryAcquire (long timeout, TimeUnit unit) is to try to obtain ...

Posted on Thu, 28 Oct 2021 12:53:24 -0400 by jennatar

Thread safety of JUC collection

List collection thread unsafe operation Collection thread unsafe case package com.atguigu.test; import java.util.ArrayList; import java.util.List; import java.util.UUID; /** * Collection thread safety case */ public class NotSafeDemo { /** * Multiple threads modify the collection at the same time * @param args */ ...

Posted on Thu, 28 Oct 2021 05:07:04 -0400 by petitduc

Synchronized underlying principle

java object and object header Locks in java Monitor heavyweight lock Monitor is translated as monitor or tube pass Synchronized is implemented through a called Monitor lock inside the object. However, the essence of Monitor lock depends on the Mutex Lock of the underlying operating system. The operating system realizes the switching b ...

Posted on Sun, 03 Oct 2021 13:47:58 -0400 by nonexistentera