Does one need to call srand() C function per thread or per process to seed the randomizer?

c++, random, random-seed, windows

Solution

According to the MSDN documentation on `srand()` (assuming you are using Microsoft's C runtime library), the seed is thread-local, so you need to call `srand()` for each thread that is using `rand()`. Note that this may not be the case in other implementations.

Quoting from MSDN:

The srand function sets the starting point for generating a series of pseudorandom integers in the current thread.

Problem

The caption pretty much says it. PS. This is for C++ Windows program.

Original source