3 ms·
How can you be sure that the other threads ever see it in time? they might be suspended for a whole second because a HDD needs to spin up or something like that
by the8472 9y ago
How can you be sure that the other threads ever see it in time? they might be suspended for a whole second because a HDD needs to spin up or something like that.
So threads never seeing the value is already a valid outcome, so the compiler might as well always do that.
- heythere124 9y agotime.Sleep(1000) could be replaced with a real syncing mechanism of some kind -- it's only for illustration.
- the8472 9y agoa real syncing mechanism would introduce compiler barriers that prevent such an optimization.