Tuesday 7 August 2012

Random number in java 7

Since java 7 you should use ThreadLocalRandom.current().nextInt() over Math.random() for generating random numbers. ThreadLocalRandom use random seed per thread, so threads do not compete for it.

No comments: