I have a global variable and multiple threads which are consistently reading the variable every few seconds.
Now I have a method in one thread which writes to the variable, and when I print out the global variable within the function where I am writing to it, I see the write has taken place and the variable value is changed as desired.
But when I read from outside the scope of the function immediately after it executes, the global variable has in fact not changed, and the write has not been successful.
Does it sound like this is due to simultaneous read/write? I'm thinking there is something going on I don't understand, though intuitively I can't see how multithreading would change anything as the global variable is being changed at least momentarily.
No writes are happening other than the one mentioned.
I haven't read up on multithreading too much so I just want a high-level "yes this is possible and makes sense with multithreading and global variables" and I will read up as necessary.