Is C# Random Number Generator thread safe? -


Can anyone tell me that C #Random Next () method is thread safe?

There is nothing special in the next method to obtain thread protection However, this is an example method if you do not share on different threads of random , then you do not have to worry about state corruption within an example.

John Skeet puts some good posts on this topic:

As noted by some commentators There is another potential problem in using different instances of random , which is thread-exclusive, but they are evenly coded, and therefore gets motivated, because of pseudo-random numbers Similar scenes, because they can be made at the same time or in close proximity to each other, one way to reduce that issue is to produce a random seed And to random example (which is to use off a thread) and start a new random example for every other thread used.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -