jeudi 17 décembre 2020

ThreadLocalRandom generate the same values across threads [closed]

I want to generate random numbers in multiple threads (more than 1000).

Following multiple advice, I used ThreadLocalRandom.current().nextInt() / nextDouble().

The problem is that in every thread, the sequence generated is exactly the same sequence.

This is not a sensitive application, so I don't need true or secure randomness, but I need all my threads to get different sequences.

The doc clearly says the seed can't be modified, and considering how useless it would be to have a dedicated thread safe PRNG generate the same sequence for all threads, I must have missed something, but I can't find it.

Any idea how to fix that? Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire