Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parallel random number generation with Akka Futures

I'm writing a CPU intensive application built with Akka 2 Futures. I don't need Actors currently but I'm not reluctant to use them.

Several computations enclosed in futures must invoke a random generator, very often. I'm afraid that if I used a classic concurrent RNG, it will become a choking point and I will lose scalability.

What is the most fast/simple way of having a Random generator per thread in the ExecutionContext ?

Is there a way to initialize them all with a different seed (but known in advance) such a to repeat experiment ?

like image 208
paradigmatic Avatar asked Mar 07 '12 10:03

paradigmatic


1 Answers

Use akka.jsr166y.ThreadLocalRandom

like image 142
Viktor Klang Avatar answered Nov 15 '22 11:11

Viktor Klang