]> git.ktnx.net Git - mobile-ledger.git/commitdiff
use a fixed thread pool for general short tasks
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 27 Aug 2021 20:02:49 +0000 (20:02 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 27 Aug 2021 20:02:49 +0000 (20:02 +0000)
app/src/main/java/net/ktnx/mobileledger/async/GeneralBackgroundTasks.java

index 438391ff5e44b652f609f4d540c06638e4d07160..3ff5904296a9bc9ce359e53f2c8a21ad1af21efb 100644 (file)
@@ -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);
     }