From fa42e4028189c8a4fb1ac80d9db30368de4c700b Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Sat, 26 Oct 2019 16:44:23 -0700 Subject: [PATCH] Limit expression thread count to processor count. --- .../worldedit/internal/expression/Expression.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java index 147378934..90e437136 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java @@ -74,11 +74,12 @@ import java.util.concurrent.TimeoutException; public class Expression { private static final ThreadLocal> instance = new ThreadLocal<>(); - private static final ExecutorService evalThread = Executors.newCachedThreadPool( - new ThreadFactoryBuilder() - .setDaemon(true) - .setNameFormat("worldedit-expression-eval-%d") - .build()); + private static final ExecutorService evalThread = Executors.newFixedThreadPool( + Runtime.getRuntime().availableProcessors(), + new ThreadFactoryBuilder() + .setDaemon(true) + .setNameFormat("worldedit-expression-eval-%d") + .build()); private final SlotTable slots = new SlotTable(); private final List providedSlots;