random numbers and multiple srand calls

前端 未结 3 1905
长情又很酷
长情又很酷 2021-01-18 09:24

I\'m writing a program that will generate numerous random numbers in loops. I\'m trying to make the numbers somewhat less predictable (not only for security, but to avoid c

3条回答
  •  耶瑟儿~
    2021-01-18 10:11

    To avoid race conditions, you need to use a separate seed variable for each thread. This means each thread will have its own separate random number sequence.

提交回复
热议问题