mirror of
https://gitee.com/dromara/sa-token.git
synced 2024-12-03 12:27:50 +08:00
修复工具类随机数重复的问题
This commit is contained in:
parent
1f99a2efba
commit
d2568577ba
@ -28,10 +28,6 @@ import cn.dev33.satoken.exception.SaTokenException;
|
||||
*
|
||||
*/
|
||||
public class SaFoxUtil {
|
||||
/**
|
||||
* 可以减少线程争用的随机对象
|
||||
*/
|
||||
private static final ThreadLocalRandom RANDOM = ThreadLocalRandom.current();
|
||||
|
||||
private SaFoxUtil() {
|
||||
}
|
||||
@ -64,7 +60,7 @@ public class SaFoxUtil {
|
||||
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < length; i++) {
|
||||
int number = RANDOM.nextInt(62);
|
||||
int number = ThreadLocalRandom.current().nextInt(62);
|
||||
sb.append(str.charAt(number));
|
||||
}
|
||||
return sb.toString();
|
||||
@ -113,7 +109,7 @@ public class SaFoxUtil {
|
||||
* @return 随机字符串
|
||||
*/
|
||||
public static String getMarking28() {
|
||||
return System.currentTimeMillis() + "" + RANDOM.nextInt(Integer.MAX_VALUE);
|
||||
return System.currentTimeMillis() + "" + ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user