Alibaba P9 Pillow Book "Principle of Java Concurrency Implementation: Analysis of JDK Source Code"

Preface

There are multi-process, multi-thread and multi-coroutine options for concurrent programming.

For Java, it is neither like C++, which calls Linux system APIs to "fork" multiple processes during operation; nor does it natively provide multiple coroutines at the language level like Go. In Java, concurrency is a multi-threaded model.

Before the release of JDK1.5, Java only provided some simple thread mutual exclusion and synchronization mechanisms at the language level, namely the synchronized keyword, wait and notify. If you encounter complex multi-threaded programming scenarios, developers need to solve complex thread synchronization problems based on these simple mechanisms. Since JDK 1.5, concurrent programming master Doug Lea has offered a systematic and comprehensive concurrent programming framework-the JDK Concurrent package, which contains various atomic operations, thread-safe containers, thread pools, and asynchronous programming.

Based on JDK 7 and JDK 8, this book conducts a comprehensive source analysis of the entire Concurrent package. The implementation of most concurrency functions in JDK 8 is the same as that of JDK 7, but some additional features have been added. For example, CompletableFuture, new implementation of ConcurrentHashMap, StampedLock, LongAdder, etc.

  • Catalog display

 

 

 

 

 

 


content

  • Multithreading basics

 


This 384-page "Java Concurrency Implementation Principle: Analysis of JDK Source Code" requires the help of a small partner after one-click and three-link, see the picture below and add a small assistant VX (gyhycx7980) to get it for free!

  • Atomic class

From the beginning of this chapter, we will analyze the hierarchy of the entire Concurrent package step by step from simple to complex, from bottom to top, as shown in the figure.

 

 

  • Lock and Condition

 

 

  • Synchronization tools

In addition to locks and conditions, the Concurrent package also provides a series of synchronization tools. Some of the principles of these synchronization tools are based on AQS, and some require special implementation mechanisms. This chapter will analyze the implementation principles of all synchronization tools.

 

 

  • Concurrent container

In the implementation of Lock and Phaser, a lock-free queue and a lock-free stack based on CAS have been introduced. This chapter will comprehensively introduce the various concurrent containers provided by the Concurrent package.

 

 

  • Thread pool and Future

Implementation principle of thread pool, class inheritance system, core data structure, graceful closing of thread pool, analysis of task execution process, 4 rejection strategies of thread pool

 

 

  • ForkJoinPool

ForkJoinPool usage-------algorithm

 

 

  • Completabl eFuture

Starting from JDK 8, a powerful asynchronous programming tool, Compl etableFuture, is provided in the Concurrent package. Before JDK 8, asynchronous programming can be achieved through thread pool and Future, but the function is not powerful enough. The emergence of Complet abl eFuture has made Java's asynchronous programming capabilities take a big step forward.
Before discussing the principle of CompletableFuture, let's take a look at the usage of CompletableFuture in detail. From these usages, we can see what capabilities have been improved compared to the previous Future.

 


The book has a total of 384 pages. All the chapters have been displayed here. Due to the copywriting reasons, it is displayed in the form of pictures. If you have different explanations, please leave a message in the discussion area.

At last

Multi-threading and concurrency is one of the knowledge points that each of our coders must master more or less. This 384-page "Java Concurrency Implementation Principle: JDK Source Analysis" will take you step by step from the basis of threads. Understand multithreading and concurrency. If you want to study in depth, then this document is very suitable for you. Due to space limitations, you can only show it in this way. If you need help from a small partner, after one-click three-connection, see the picture below plus a small assistant VX (gyhycx7980 ) Can be obtained for free!

Guess you like

Origin blog.csdn.net/GYHYCX/article/details/113280471