Almost every pseudorandom generator in C/C++ (Mersenne, ...) uses some kind of internal state, usually a short vector of bytes. My question is, when such a random generator is used and shared in a multithreaded environment is it "much" better to have it thread-safe or letting "race conditions" to occur can only increases randomness?
I know this question is extremely hard to answer rigorously but will appreciate any opinions.
Letting "race conditions" occur can mess up everything. Technically, a data race is undefined behaviour, so it could order pizza.
But even if that doesn't happen, the internal state is likely to get corrupted and all important properties of the random sequence will just be lost. You can no longer guarantee uniformity, for example. You can't leave the generation of random numbers to chance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With