D
ds
Hi all,
rand() is not thread safe, a fact that may not be so bad after all..
However, I face the following problem: a piece of code uses rand() to
get a random sequence, but always seeds with the same seed for
reproducibility of the results. Now I am porting this (old C89) code
and have setup a nice app with threads that drives on one thread the
old code and on another the new code, so that I can compare the
results and see that nothing changed. Alas, rand() is not thread safe
so even though both versions seed with the same number, consecutive
rand() calls do not yield the same number for each thread... I would
like to setup a workaround in the new code only rather than make
changes to the old code as well. Any ideas?
Thanks a lot in advance!!!!
BR
-- ds
rand() is not thread safe, a fact that may not be so bad after all..
However, I face the following problem: a piece of code uses rand() to
get a random sequence, but always seeds with the same seed for
reproducibility of the results. Now I am porting this (old C89) code
and have setup a nice app with threads that drives on one thread the
old code and on another the new code, so that I can compare the
results and see that nothing changed. Alas, rand() is not thread safe
so even though both versions seed with the same number, consecutive
rand() calls do not yield the same number for each thread... I would
like to setup a workaround in the new code only rather than make
changes to the old code as well. Any ideas?
Thanks a lot in advance!!!!
BR
-- ds