as the title shows, many books and materials do not explicitly mention which operations are atomic, which is very important in writing concurrent programs.
as the title shows, many books and materials do not explicitly mention which operations are atomic, which is very important in writing concurrent programs.
1: access, reading and writing of basic data types are atomic (main note: for 32-bit operating systems, the maximum length that can be processed by a single operation is 32bit, while the long type is 8-byte 64bit, so it takes two instructions to read and write to long (that is, the 32bit in 64bit each time). )
2: synchronization block (synchronized keyword)