Multithreading: simultaneous read/write?

I'm rewriting a console app to include a GUI. The original was single-threaded, so this inevitably introduces a bunch of data races. When an address is written to and read from concurrently, will the write operation complete normally?

I wouldn't mind having an incorrect value displayed every few billion iterations, but I'd rather not risk data getting corrupted.
To ensure that the pointer is valid across the threads make the pointer atomic:

http://www.cplusplus.com/reference/atomic/atomic/?kw=atomic

There might be even no time overhead if the processor instruction is alread atomic.

However you must ensure the any shared data is protected in case of simultaneous read a write.
Topic archived. No new replies allowed.