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 ...