SyntaxFix
Write A Post
Hire A Developer
Questions
Java 7 introduced ThreadLocalRandom which is isolated to the current thread.
This is an another rendition of maerics's solution.
final byte[] bytes = new byte[20]; ThreadLocalRandom.current().nextBytes(bytes);