How to synchronize shared memory access? multithreading?

Ok, I’ll try to change the logic of the game to try to avoid this situation. Thank you very much for your explanation, it has been very useful for me to know what is really happening.