Java Concurrency Programming-master

Source: Internet
Author: User
Tags semaphore

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.