Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Random multithreading
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-11-14 14:19:47


AMDG

On 11/14/2010 7:03 AM, Juan Antonio Farré Basurte wrote:
> Are random number generators thread safe? Can I use a random number
> generator by multiple threads without explicit locking?

No.

> I guess the answer is no... Then I wonder if every thread could use a
> different instance of the same random number generator without interference
> between the different generators.
>
> I guess the answer is yes for pseudorandom generators. But what about
> real random generators? If I have different instances of one, they all have
> to access the same source of randomness (maybe hardware). Will they
> synchronize transparently?

random_device reads from /dev/urandom. I assume that
this is safe.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net