On Mon, Apr 12, 2010 at 12:59 PM, Dave Whipp <d...@dave.whipp.name> wrote:

> 2a. If I spawn two threads (implicitly or explicitly), how do their RNGs
> interact? I.e. are C<rand> and C<pick> thread-safe?

I've noticed that this is a potentially-surprising source of lock contention
in Java - all threads share common RNG state, access to which is therefore
protected by locks, so if you have multiple threads generating random
numbers, things slow down tremendously.  An easy way to get a per-thread RNG
would be very handy.

I think that all that is needed is to permit some sort of declaration/pragma
> that creates a dynamic scope for an srand: e.g. "temp srand { ... };"

That seems like a reasonable solution.

Mark J. Reed <markjr...@gmail.com>

Reply via email to