Is the behavior of rand() across different threads defined? I just spent twenty minutes trying to figure out why I was getting the same sequences in each run even though I was calling srand(time(0)) on the first line of main() until I realized rand() was being called from a threads other than main(). I added a call to srand() to each thread and it works, now. What could possibly be the point of having rand() behave like this? Maybe avoid race conditions?
In a word, no. rand() behavior across threads is going to be implementation dependant. I would hazzard a guess you are using a Microsoft compiler. They require rand() to be separately seeded for each thread. Why? I have no idea. Some other compilers only require rand() to be seeded once, and this seed will affect all threads.