forked from External/mage
refactor : removed all instances of new Random() and replaced with RandomUtil for a ThreadLocal randomizer
This commit is contained in:
parent
f2cc8d4571
commit
e2a479255a
51 changed files with 173 additions and 133 deletions
28
Mage/src/main/java/mage/util/RandomUtil.java
Normal file
28
Mage/src/main/java/mage/util/RandomUtil.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package mage.util;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* Created by IGOUDT on 5-9-2016.
|
||||
*/
|
||||
public class RandomUtil {
|
||||
|
||||
private static ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||
|
||||
public static Random getRandom(){
|
||||
return random;
|
||||
}
|
||||
|
||||
public static int nextInt(){
|
||||
return random.nextInt();
|
||||
}
|
||||
|
||||
public static int nextInt(int max){
|
||||
return random.nextInt(max);
|
||||
}
|
||||
|
||||
public static boolean nextBoolean() {
|
||||
return random.nextBoolean();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue