In a multi-threaded C++ desktop application, if the main thread has a main loop where:
- It reads/write to a variable and then
- Invokes thread that reads/writes to that variable
Does that variable need to be synchronized if the reading/writing between the main thread and the worker thread never happens at the same time? That is the main thread reads/writes to the variable, invokes the thread(s), then waits for the threads to complete before reading/writing the variable again.