Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What are the atomic operations in java?
What are the atomic operations in java?
13 is ok, 24 is not, but that's not what it means upstairs. Atomic operations can be viewed in combination with multithreading.

First of all, you should know what atomic operation is. My understanding is that operations that conform to multi-thread atomic operations are called atomic operations.

The atom is the smallest unit in the world and inseparable. For example, a = 0;; (A is not of type long and double) This operation

Is inseparable, then we say this operation is atomic operation. Another example is: a++;+; +; This operation is actually a = a+1;

Is separable, so it is not an atomic operation.

For example, there is no problem when you perform the operation a = 1, but there is a big problem when you perform A = B.

If other threads change the value of b at this time, then a = b will have different results, because you are not sure about the value of b,

For example, if your first expectation is a = b, and you think that the value of B is 3, then A is also 3, but in the case of multithreading, the program makes B become.

4, then A becomes 4, then this is not an atomic operation.