Files
java-core-examples/random/output/03-threadlocalrandom.txt
T

13 lines
337 B
Plaintext

== The one correct way to call it ==
ThreadLocalRandom.current().nextInt(1, 7) -> in 1..6: true
== It cannot be seeded ==
setSeed(42) -> UnsupportedOperationException, message: null
== Each thread has its own state ==
4 threads, distinct first values: 4 of 4
== Works the same on virtual threads ==
virtual thread rolled a die: true