Java 7: ThreadLocalRandom generating the same random numbers

前端 未结 3 1235
眼角桃花
眼角桃花 2020-12-31 05:38

I\'m trying out Java 7\'s ThreadLocalRandom and see that it is generating exactly the same random numbers across multiple threads.

Here is my code, in which I creat

3条回答
  •  温柔的废话
    2020-12-31 05:41

    Isn't this because the threads are being created at roughly the same time and thus getting seeded the same value from the timer? I was under the impression that was how that worked, though I may be mistaken.

提交回复
热议问题