Re: how good is .NET's Random for making random numbers?

Tech-Archive recommends: Fix windows errors by optimizing your registry




"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message news:MPG.20b4b60440ccff79107@xxxxxxxxxxxxxxxxxxxxxxx
Jon Davis <jon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I always create a exactly one single static Random object with my app and
seed it with DateTime.Now.Ticks.

Random already seeds itself with Environment.TickCount if you don't
provide any constructor parameters.

True, but specifying the ticks gives me a stub I can modify later.

You need to watch for using a single object in a multi-threaded
situation though - Random isn't thread-safe.

Since Next() always scrambles its seed, regardless of calling thread, why is this of concern?

Jon

.



Relevant Pages