There is no arr, but that’s just a typo.
I agree with Spiros.
sb1.ar and
sb2.ar are initialized; they point to
ar[0] and ar[500000] respectively. The contents of the ar array on
main’s stack are not initialized, so both threads will do an
uninitialized read on every iteration.
If the example was simpler it would be more likely to be correct l-)
--
https://www.greenend.org.uk/rjk/