Skip to content

Commit

Permalink
Merge pull request #28 from Dreeam-qwq/fix/get-tps-cme
Browse files Browse the repository at this point in the history
Use CopyOnWriteArrayList to avoid CME in getTPS
  • Loading branch information
tiredvekster authored Aug 6, 2024
2 parents 2fa4535 + 7686e43 commit a713d1d
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import me.vekster.lightanticheat.util.scheduler.Scheduler;

import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class TPSCalculator {

Expand All @@ -21,7 +20,7 @@ public class TPSCalculator {
static {
Double[] tps = new Double[CACHE_DURATION_IN_SEC / CHECK_INTERVAL_IN_SEC];
Arrays.fill(tps, 20.0);
TPS = Collections.synchronizedList(new LinkedList<>(Arrays.asList(tps)));
TPS = new CopyOnWriteArrayList<>(Arrays.asList(tps));
}

public static void loadTPSCalculator() {
Expand Down

0 comments on commit a713d1d

Please sign in to comment.