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

后端 未结 4 1568
借酒劲吻你
借酒劲吻你 2021-01-11 16:46

The caption pretty much says it.

PS. This is for C++ Windows program.

4条回答
  •  心在旅途
    2021-01-11 17:14

    Be aware that the state is fiber-local (which is more fine-grained than thread-local). Thus, srand has to be called for each fiber. (Of course, when you don't use fibers it's equivalent to thread-local.)

提交回复
热议问题