Java native support concurrency, basic underlying synchronization includes:
Synchronized, used to indicate a method (normal, static) or a block that needs to be executed synchronously (at some point, only one thread is allowed to execute a block of code).
Volatile, which identifies a variable as a shared variable (threads are not cached), and updates and reads are atomic.
Wait, the thread waits for an event on an object (notify event, thread hangs, release lock) and needs to be executed in the synchronized area.
Notify, after an event occurs, notifies the event that a suspended thread needs to be executed in the synchronized area.
Notifyall, after the event occurs, notifies all pending threads that it needs to be executed in the synchronized area.
Java Concurrent Programming tool classes are located under the Java.util.concurrent package and can be divided into the following categories:
(1) Execution Unit
Runnable, which identifies an interface in which a class is an executable unit, does not care about the return result of the child thread and the exception State (Functionalinterface).
Callable, an interface that identifies a class as an executable unit, needs to know the return result of the child thread and the exception State (Functionalinterface).
Future, the result of callable execution.
Thread, threading (runnalbe default implementation Class).
(2) Synchronizer
The Java synchronizer, which is a number of classes used to synchronize between multiple threads, is located under the Java.util.concurrent package:
Countdownlatch, latching, used for one or more threads to wait for an event set to occur, and a set of threads to synchronize with the main thread.
Cyclicbarrier, level, for a group or groups of threads to agree on a point in time for the next move.
Exchanger, a switch that is used for synchronization between two threads (data exchange).
Phaser, Phase shifter, which combines the functions of countdownlatch and Cyclicbarrier, is the newly introduced Synchronizer in Java 7, and its main feature is to support dynamic additions and deletions, one-way synchronization, and phase-splitting operations.
Semaphore, a semaphore that is used to limit the license management of resources during multithreaded access.
(3) Concurrency data structure
Queue&deque,
List,
Map,
Set,
(4) Executor frame set
Executor,
Executorservice,
Executors,
Executorcompletionservice,
Scheduledexecutorservice,
Scheduledfuture,
Scheduledthreadpoolexecutor,
(5) Fork-join frame set
Forkjointask,
Forkjoinpool,
Recursivetask,
Recursiveaction,
Forkjoinworkerthread,
(6) Atomic variable class (java.util.concurrent.atomic)
Atomicboolean,
Atomicinteger,
Atomicintegerarray,
Atomicintegerfieldupdater,
Atomiclong,
Atomiclongarray,
Atomiclongfieldupdater,
Atomicreference,
Atomicreferencearray,
Atomicreferencefieldupdater,
Atomicmarkablereference,
Atomicstampedreference,
(7) Java Advanced Lock (Java.util.concurrent.locks)
Lock,
Condition,
Abstractqueuedsynchronizer,
Reentrantlock,
Readwritelock,
Reentrantreadwritelock,
Stampedlock,
(8) Other
ThreadLocal,
Java Concurrency Programming-master