Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Random numbers with multiple threads

1 view
Skip to first unread message

ntman

unread,
Jun 6, 2009, 11:14:01 AM6/6/09
to
Please could some kind person explain how to generate random numbers that
have a different sequence in different threads.

In my main thread I'm using srand seeded by time, then in each thread I'm
using rand. Whilst the numbers generated in each thread are random, each
thread gets the SAME sequence of random numbers. I've having to use srand
seeded with the time and the thread id before each call to rand to get true
random numbers in each thread that are different in each thread.

Is there a better way to do this please? (not using .net)

John.

0 new messages