From 558635f35049d8ae0bffdb87422772ed97614b41 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 27 Aug 2021 20:02:49 +0000 Subject: [PATCH] use a fixed thread pool for general short tasks --- .../net/ktnx/mobileledger/async/GeneralBackgroundTasks.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/async/GeneralBackgroundTasks.java b/app/src/main/java/net/ktnx/mobileledger/async/GeneralBackgroundTasks.java index 438391ff..3ff59042 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/GeneralBackgroundTasks.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/GeneralBackgroundTasks.java @@ -25,8 +25,12 @@ import org.jetbrains.annotations.Nullable; import java.util.concurrent.Executor; import java.util.concurrent.Executors; +/** + * suitable for short tasks, not involving network communication + */ public class GeneralBackgroundTasks { - private static final Executor runner = Executors.newCachedThreadPool(); + private static final Executor runner = Executors.newFixedThreadPool(Runtime.getRuntime() + .availableProcessors()); public static void run(@NotNull Runnable runnable) { runner.execute(runnable); } -- 2.39.5