fix
parent
ee902be8ea
commit
6ddd6930ec
|
|
@ -3,6 +3,7 @@ package com.ljsd.jieling.util;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -14,6 +15,8 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||||
public class MathUtils {
|
public class MathUtils {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(MathUtils.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(MathUtils.class);
|
||||||
|
|
||||||
|
private static final Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权重随机
|
* 权重随机
|
||||||
* @param rateArray
|
* @param rateArray
|
||||||
|
|
@ -82,4 +85,8 @@ public class MathUtils {
|
||||||
return low + ThreadLocalRandom.current().nextInt(hi - low + 1);
|
return low + ThreadLocalRandom.current().nextInt(hi - low + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int randomInt(int n){
|
||||||
|
return random.nextInt(n);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue