Is Windows' rand_s thread-safe?-Collection of common programming errors
I don’t know if rand_s is thread-safe, but it seems like it probably is, since it seems to make a round-trip to the OS for entropy. (as long as you link to the VC++ multi-thread CRT, all bets are off if you link to the single-thread one)
If it’s supported by windows CRT, you can try a call to rand_r which is the posix reentrant version of rand. OR even better boost::random, if you’re already using boost.
considering how pervasive multi-threading will be soon, no one should be using rand() anymore in new code – always try to use rand_r/rand_s/boost/various platform-dependent secure rands/etc.