Is it possible that the last line shows any number other than 1337
or 0
due to a race condition?
static mut FOO: i32 = 1337;
// en hilo 1
unsafe { FOO = 0; }
// en hilo 2
unsafe { println!("{}", FOO); }
I imagine it FOO
could be read while writing, when only a few bits have been updated, if the operations are performed in different threads.
If possible. Whenever you work with multithreading, it is recommended to use Atomic.
rust doc