fix for the RandomUtil, always use .current() to get the correct thread.

This commit is contained in:
ingmargoudt 2016-09-14 09:11:26 +02:00
parent 5289dd3df8
commit e62241c3eb

View file

@ -8,21 +8,18 @@ import java.util.concurrent.ThreadLocalRandom;
*/ */
public class RandomUtil { public class RandomUtil {
private final static ThreadLocalRandom random = ThreadLocalRandom.current();
public static Random getRandom() { public static Random getRandom() {return ThreadLocalRandom.current();}
return random;
}
public static int nextInt() { public static int nextInt() {
return random.nextInt(); return ThreadLocalRandom.current().nextInt();
} }
public static int nextInt(int max) { public static int nextInt(int max) {
return random.nextInt(max); return ThreadLocalRandom.current().nextInt(max);
} }
public static boolean nextBoolean() { public static boolean nextBoolean() {
return random.nextBoolean(); return ThreadLocalRandom.current().nextBoolean();
} }
} }