I have the following situation (caused by a defect in the code):
There's a shared variable of primitive type (let it be int
) that is initialized during program startup from strictly one thread to value N
(let it be 0
). Then (strictly after the variable is initialized) during the program runtime various threads are started and they in some random order either read that variable or overwrite it with the very same value N
(0
in this example). There's no synchronization around accessing the variable.
Can this situation cause unexpected behavior in the program?