I need a little clarification about thread-safety. I understand that some simple operations, like incrementing an index, might not be atomic, but I'm wondering about the case below.
I have a program with two threads. The second thread runs a loop. It's index is copied to a global variable, which the main thread uses to update the UI. Something like this:
The main thread only reads from gIndex, and never changes it. Is this thread-safe?Code:for(i = 0; i < max; i ++) { ... gIndex = i; ... }
Thanks!