Java Juc Series (01)--Basic overview of "atomicity" __java

Source: Internet
Author: User

First, Juc basic introduction
JUC (Java Util concurrency): Java Concurrency Tool class.

As you can see from the diagram above, the Java Concurrency Tool class consists primarily of five parts.

Atomic:atomicinteger, Atomiclong, atomicreference
locks:lock, Condition, Readwritelock collections:queue
, Concurrentmap
executer:future, callable, Executor
Tools:countdownlatch, Cyclicbarrier, semaphore

Ii. Basic concepts of atomic class

First we learned that the definition of thread-safe = = In Java concurrency programming is as follows: When multiple threads access a class, it is not necessary to consider the scheduling and alternating running of these threads in the run-time environment, and there is no need for additional synchronization and no other coordination is required to invoke the code. The behavior of this class is still correct, then the class is thread safe.
as we can see from this definition, it is obvious that the thread is unsafe only when resources compete, so stateless objects are always thread-safe.
= = Atomic Operation = = Description: When multiple threads perform an operation, either of these threads performs the operation completely or does not perform any of the steps of this operation, then the operation is atomic. That is, atomic class operations are operations that cannot be interrupted by the thread dispatch mechanism.

Article just as their own learning notes, learn from the many cases on the Internet, if you think wide to the words, hope to exchange more, in this thank ...

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.