0
Question on race condition
Hi I have a function and it has a local variable..... As thread have their own stack frame, we dont have data race condition for local variables.... Is this true ? Also data race happens when we have global variable and both the thread writes or one reads and one writes..... in these two conditions, data race may occur.... if both the threads only reads data from global variable, data race does not happen... Is above all details correct ?
1 Respuesta
+ 1
True, having all local variables prevents data race condition, as long as none of the local variables are static. Use only dynamic local variables.
True, a data race only occurs when you have writable shared state space.