What is a thread-safe random number generator for perl?

Question!

The core perl function rand() is not thread-safe, and I need random numbers in a threaded monte carlo simulation.

I'm having trouble finding any notes in CPAN on the various random-number generators there as to which (if any) are thread-safe, and every google search I do keeps getting cluttered with C/C++/python/anything but perl. Any suggestions?

By : BrunoXSLT


Answers

rand is thread safe, and I think you got the wrong definition of what "thread safe" means, If its not "thread safe" It means the program/function is modifying its "shared" data structure that makes its execution in thread mode unsafe.

Check Rand function documentation, Notice it take EXPR as argument, in every thread you can provide a different EXPR.

http://perldoc.perl.org/functions/rand.html



Do you have /dev/urandom on your system?

BEGIN {
    open URANDOM, '
By : mob


This video can help you solving your question :)
By: admin