线程卡死玩家无法进入游戏
parent
1d28d4e51d
commit
c4471cb7f9
|
|
@ -174,9 +174,15 @@ public class MathUtils {
|
|||
* @return
|
||||
*/
|
||||
public static List<Integer> randomForOneArray(int sourceArray[], int randomNums) {
|
||||
|
||||
List<Integer> result = new ArrayList<>();
|
||||
if(randomNums==0){
|
||||
return result;
|
||||
}
|
||||
int length = sourceArray.length;
|
||||
Set<Integer> cacheIndexs = new HashSet<>();
|
||||
|
||||
// 这种while循环我觉得还是尽量避免下 或者一定要有个循环上限
|
||||
while (randomNums>0){
|
||||
int randomPos = randomInt(length);
|
||||
if(cacheIndexs.contains(randomPos)){
|
||||
|
|
|
|||
Loading…
Reference in New Issue