diff options
author | Luck <git@lucko.me> | 2022-01-09 17:11:22 +0000 |
---|---|---|
committer | Luck <git@lucko.me> | 2022-01-09 17:11:22 +0000 |
commit | 077590bf3af2c3e27d05f138b3023e86e56fe34a (patch) | |
tree | cc5f832162306e79313308427b3d2ed4a882c4db /spark-common/src/main/java/me/lucko | |
parent | 5bbd0ebf0db436d4a764163618c577783f4a9e08 (diff) | |
download | spark-077590bf3af2c3e27d05f138b3023e86e56fe34a.tar.gz spark-077590bf3af2c3e27d05f138b3023e86e56fe34a.tar.bz2 spark-077590bf3af2c3e27d05f138b3023e86e56fe34a.zip |
Use thread safe collections in TickHook and TickReporter (#155)
Diffstat (limited to 'spark-common/src/main/java/me/lucko')
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/common/tick/AbstractTickHook.java | 4 | ||||
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/common/tick/AbstractTickReporter.java | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/tick/AbstractTickHook.java b/spark-common/src/main/java/me/lucko/spark/common/tick/AbstractTickHook.java index a6e8745..2a31e0d 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/tick/AbstractTickHook.java +++ b/spark-common/src/main/java/me/lucko/spark/common/tick/AbstractTickHook.java @@ -20,12 +20,12 @@ package me.lucko.spark.common.tick; -import java.util.HashSet; import java.util.Set; +import java.util.concurrent.CopyOnWriteArraySet; public abstract class AbstractTickHook implements TickHook { - private final Set<Callback> tasks = new HashSet<>(); + private final Set<Callback> tasks = new CopyOnWriteArraySet<>(); private int tick = 0; protected void onTick() { diff --git a/spark-common/src/main/java/me/lucko/spark/common/tick/AbstractTickReporter.java b/spark-common/src/main/java/me/lucko/spark/common/tick/AbstractTickReporter.java index 74a814d..431a641 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/tick/AbstractTickReporter.java +++ b/spark-common/src/main/java/me/lucko/spark/common/tick/AbstractTickReporter.java @@ -20,11 +20,11 @@ package me.lucko.spark.common.tick; -import java.util.HashSet; import java.util.Set; +import java.util.concurrent.CopyOnWriteArraySet; public abstract class AbstractTickReporter implements TickReporter { - private final Set<Callback> tasks = new HashSet<>(); + private final Set<Callback> tasks = new CopyOnWriteArraySet<>(); protected void onTick(double duration) { for (Callback r : this.tasks) { |