richard_damon wrote on Friday, July 21, 2017:
When you get into Multiple Writers, Multiple Readers, the big question comes to what do you mean by this and what are behavior are you expecting. At the simple level, it still will just work with a simple atomic int. The variable will have the value last written when every reader reads it. That means if one task writes a value of 5, then another task writes the value 10, after that point all readers will see the 10, and a reader which reads between the two writes will see a 5. If there is no interactions between the writers to synchronize the writes, then it is possible that under other conditions, the 10 might have occurred first, and then the final value would be the 5, so you have some uncertainty due to the ‘race’ condition. Similarly for the readers, if there is nothing synchronizing them to the writers, eventually they will see the later value, but if they happen to read before the last write, they will see the earlier write. Another ‘race’ condition.
Normally, this sort of variability isn’t desired, but there are conditions where it might be acceptable. Thus definition is needed.