2 ms·
Math.random() should be used only for tests. That's it. Performance sucks as it's shared. ThreadLocalRandom is a lot better if you need fast but not-quality ran
by xxs 12y ago
Math.random() should be used only for tests. That's it.
Performance sucks as it's shared. ThreadLocalRandom is a lot better if you need fast but not-quality random.
And there is SecureRandom for security concerns.
Last fun fact Math.random() and a Monte Carlo test introduced "CAS in Java" and all that followed with JSR 166.