Before we want to talk about Java Contract issuance (java.util.concurrent) When , It's a headache , But every one of them Java A skill that engineers have to master . Always wanted to write a Java And contract series , But I didn't use my hands and brain . Recently, I reconsidered and planned my own learning route , Decided to go from Java And start putting every technology 、 principle 、 Source code made into a series , from the shallower to the deeper , from the outside to the inside .
This is a Java And the beginning of the contract , I'll give you a general introduction, from a more macro perspective Java Contract issuance , And some general ideas of this series .
java.util.concurrent from jdk1.5 Start a new package , We are committed to solving the thread safety problem of concurrent programming , So that users can write multithreaded concurrent programs more quickly and conveniently . When it comes to thread safety, there are always several core issues : lock 、 Blocking 、 Atomicity 、 Visibility and so on .

-java.util.concurrent
-atomic
-locks

stay concurrent There are two more bags under the bag , One is atomic Here are some atomic classes , For example, in a multithreaded environment i++ The operation of is actually i+1 And then assign the result to i, This will involve a thread safety issue , When a thread is executing i+1 When , It's very likely that another thread is reading i Value , This will cause data inconsistency , It's a matter of atomicity . Just in time, a thread completes i++ The operation of , And another thread reads it at this point i It is also possible to find i It's not the added value , It's a matter of visibility .atomic Inside AtomInteger Can perfectly solve the problems of atomicity and visibility .
The other bag is locks, This package can be said to be the most basic tool for thread safety —— Display lock (ReentrantLock、ReadWriteLock).Java There is synchronized Modified synchronous code block with built-in lock , But this is far from satisfying some advanced features , For example, by polling 、 Get a lock in a timed way , And the flexibility of the display lock in the contract is higher than synchronized, But then it becomes more difficult to use , Improper use can lead to unknown consequences .
concurrent Under the package are some concurrent tool classes , Common are ConcurrentHashMap、ArrayLinkedQueue、LinkedLinkedQueue…… These are thread safe classes , Select different classes according to different situations .
At the beginning of this series, I will first introduce some basic knowledge and technical terms about threads , for example : Threads and processes 、 Blocking and non blocking 、 Thread safety 、 Atomicity 、 Visibility and so on , Sometimes it might be “ Superclass ”, The super outline part is briefly described . Then we will start from the examples and introduce them in different categories, as well as the source code , Source code to jdk1.7 Mainly , Sometimes it's possible to design the latest jdk1.8 Even jdk1.6, This will be specially marked with . In the end, I will be right Java And make a summary overview .
That's all Java And the beginning of the series . If there is a mistake , Please leave a comment .

0.Java And more related articles at the beginning of the series

  1. Java Container Analysis series (0) The opening

    Recently, I just finished learning the data structure and algorithm : Data-Structures-and-Algorithm-Analysis Want to combine Java The container class in , Because I was right Java The understanding of container class is not very deep , ...

  2. Java And contract source learning series :CLH Synchronization queue and synchronization resource acquisition and release

    Catalog The learning objectives of this article CLH The structure of the queue The resource acquisition The team Node addWaiter(Node mode) Keep trying Node enq(final Node node) boolean acquireQue ...

  3. Java And contract source learning series :AQS The difference between sharing and exclusive resource acquisition and release

    Catalog Java And contract source learning series :AQS Sharing mode gets and releases resources Exclusive access to resources void acquire(int arg) boolean acquireQueued(Node, int) Exclusive release ...

  4. Java And contract source learning series :ReentrantLock Reentrant exclusive lock details

    Catalog Introduction to basic usage Inheritance system Construction method state State means Get the lock void lock() Method NonfairSync FairSync The difference between fair and unfair strategies void lockInterrupti ...

  5. Java And contract source learning series :ReentrantReadWriteLock Read write lock parsing

    Catalog ReadWriteLock Read write lock Overview Read write lock case ReentrantReadWriteLock Architectural Overview Sync Important fields and inner class representation Write lock acquisition void lock() boolean writ ...

  6. Java And contract source learning series : Detailed explanation Condition Condition queue 、signal and await

    Catalog Condition Interface AQS The support of conditional variables ConditionObject Inner class review AQS Medium Node void await() Add to the condition queue Node addConditionWaite ...

  7. Java And contract source learning series :JDK1.8 Of ConcurrentHashMap The source code parsing

    Catalog Why use ConcurrentHashMap? ConcurrentHashMap Structural characteristics of Java8 Before Java8 after Basic constants Important member variables Construction method tableSizeFor put ...

  8. Java And contract source learning series : Blocking queues BlockingQueue And the realization principle analysis

    Catalog The main point of this article is What is blocking queue Methods provided by blocking queues Seven implementations of blocking queues TransferQueue and BlockingQueue The difference between 1.ArrayBlockingQueue 2.LinkedBloc ...

  9. Java And contract source learning series : Blocking queue implementation ArrayBlockingQueue The source code parsing

    Catalog ArrayBlockingQueue summary Class diagram structure and important fields Constructors Out and in operations The team enqueue Out of the team dequeue Blocking operations E take() Block access void put(E e) ...

Random recommendation

  1. 2015-01-19 .Net Software engineer Pen test

    Completion 1.String yes __ type ( Value type or reference type ) 2.int The base class of is __ 3. Realization __ Class , Can be applied foreach sentence 4. To output a paragraph XML file , use __ Class to ensure that the output is properly formatted XML, Output ...

  2. scrapy System learning (1)-- Summary

    This article describes the operating environment :ubuntu14.04 One . install Scrapy/Mysql/MySQLdb Refer to the official website tutorial to install Scrapy #sudo apt-key adv --keyserver hkp://keyse ...

  3. MSI/MSI-X

    MSI PCI2.2 The norm introduces MSI As an alternative to traditional line based interruptions .MSI Allow the device to allow interrupts by writing a specific value to a specific address , Instead of using a dedicated pin to trigger interrupts . Note that the destination address of the message and the message data are treated as ...

  4. Dorado Parameters of the event

    onClick,onSuccess Events are usually just 2 Parameters (self,arg), In fact, parameters can be added . You can put the ID Put it directly into the parameters , And then in the event editor directly through ID As a control object , Just set the value directly , Don't type ...

  5. (H5)FormData+AJAX+SpringMVC Upload files asynchronously across domains

    I haven't had time to sort out the information recently , You should understand the business as soon as you enter the company , I was killed by business all day . To sum up, I had a morning's cross domain asynchronous file upload . The main technologies used are HTML5 Of FormData,AJAX,Spring MVC. First look at the next upload page ...

  6. nginx+tomcat+session share ( turn )

    1 cause   The latest development of web The system has been pressure tested , Find out tomcat The default configuration is down to 600 People's concurrent login home page response speed has a more serious impact , One round 2000 More than one 500 and 502 error . I did the statistics of login time ...

  7. Java 9 reveal (7. Create a custom runtime image )

    Tips Be a lifelong learner . In the first chapter , It mainly introduces the following contents : What is a custom runtime image and JIMAGE Format How to use jlink Tools to create custom runtime images How to specify a command name to run an application stored in a custom image ...

  8. ES6( The number )

    New features in numerical processing : 1. The new method 2. Method adjustment 1. Binary and octal Binary in 0b start , among B and b Fine : Octal to 0o start , among O and o Fine . 2. Judge whether the value is valid ( Co., LTD. ) NaN It's not a number , So it's ...

  9. Use Intel IPT Technology to protect your account security

    Use Intel IPT Technology to protect your account security

  10. Java 8 New, special, new Tool class ZonedDateTime

    class ZonedDateTime java.lang.Object Inherit java.time.ZonedDateTime All implemented interfaces : Serializable,Comparable < Chro ...