I recently started reading about programming in Assembly. To my knowledge, in Assembly, a programmer, when storing and retrieving their variables, has to specify the address their variables are stored in from the RAM register to the CPU.
Now my question is: What if in multi threaded CPUs, two programs that a user runs and both programs tries to access the same memory address at the same time either reading or writing, what happens? How would one prevent this?