On a 32-bit computer, assigning or getting a value to a variable of type _int64 is a two-step operation at the CPU instruction level, writing or reading the first 32 bits and the last 32 bits of the memory respectively. If other threads read and write this variable between these two CPU instructions, concurrency problems will occur. For example: Thread 1 first writes the first 32 bits of the variable, then thread 2 writes the first 32 bits and last 32 bits of the variable, then thread 1 writes the last 32 bits of the variable 32 bits. The final result is that the first 32 bits of the memory are written by thread 2, and the last 32 bits are written by thread 1. The data in memory ends up being a completely wrong data.
Intel’s 32-bit CPU ensures that no matter how many threads are accessing the memory, only one thread is accessing the same byte, double byte, or quad byte at the same time. Use a 32-bit CPU to read and write eight-byte data. When most compilers implement this function, they read and write four-byte data twice from a programming perspective. So - you can't guarantee that when you read and write the first four-byte data, other threads will be writing and reading the second four-byte data.
On a 32-bit computer, assigning or getting a value to a variable of type _int64 is a two-step operation at the CPU instruction level, writing or reading the first 32 bits and the last 32 bits of the memory respectively. If other threads read and write this variable between these two CPU instructions, concurrency problems will occur.
For example:
Thread 1 first writes the first 32 bits of the variable,
then thread 2 writes the first 32 bits and last 32 bits of the variable,
then thread 1 writes the last 32 bits of the variable 32 bits.
The final result is that the first 32 bits of the memory are written by thread 2, and the last 32 bits are written by thread 1. The data in memory ends up being a completely wrong data.
This is multi-threaded, which means that Int64 is not an atomic operation. Common concurrency problems will occur during multi-threaded operations
Intel’s 32-bit CPU ensures that no matter how many threads are accessing the memory, only one thread is accessing the same byte, double byte, or quad byte at the same time.
Use a 32-bit CPU to read and write eight-byte data. When most compilers implement this function, they read and write four-byte data twice from a programming perspective. So - you can't guarantee that when you read and write the first four-byte data, other threads will be writing and reading the second four-byte data.