diff options
author | Luck <git@lucko.me> | 2021-12-28 22:31:49 +0000 |
---|---|---|
committer | Luck <git@lucko.me> | 2021-12-28 22:31:49 +0000 |
commit | 1dd973f7317734d47dcb9879070daee76ca4b6b7 (patch) | |
tree | a4a4c719194205fb88978ce299b59e4b5f953e5e /spark-fabric/src/main/java/me/lucko/spark | |
parent | 7e96297d27f78b14354ee1391dc3808b240b19f7 (diff) | |
download | spark-1dd973f7317734d47dcb9879070daee76ca4b6b7.tar.gz spark-1dd973f7317734d47dcb9879070daee76ca4b6b7.tar.bz2 spark-1dd973f7317734d47dcb9879070daee76ca4b6b7.zip |
Add timeout thread to detect stuck commands
Diffstat (limited to 'spark-fabric/src/main/java/me/lucko/spark')
-rw-r--r-- | spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricSparkPlugin.java | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricSparkPlugin.java b/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricSparkPlugin.java index 4bcfce4..7b0af11 100644 --- a/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricSparkPlugin.java +++ b/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricSparkPlugin.java @@ -35,6 +35,7 @@ import me.lucko.spark.common.SparkPlugin; import me.lucko.spark.common.command.sender.CommandSender; import me.lucko.spark.common.sampler.ThreadDumper; import me.lucko.spark.common.util.ClassSourceLookup; +import me.lucko.spark.common.util.SparkThreadFactory; import me.lucko.spark.fabric.FabricClassSourceLookup; import me.lucko.spark.fabric.FabricSparkMod; @@ -60,12 +61,7 @@ public abstract class FabricSparkPlugin implements SparkPlugin { protected FabricSparkPlugin(FabricSparkMod mod) { this.mod = mod; this.logger = LogManager.getLogger("spark"); - this.scheduler = Executors.newSingleThreadScheduledExecutor(r -> { - Thread thread = Executors.defaultThreadFactory().newThread(r); - thread.setName("spark-fabric-async-worker"); - thread.setDaemon(true); - return thread; - }); + this.scheduler = Executors.newScheduledThreadPool(4, new SparkThreadFactory()); this.platform = new SparkPlatform(this); } |