diff --git a/src/main/java/me/kavin/piped/utils/Multithreading.java b/src/main/java/me/kavin/piped/utils/Multithreading.java index 2b0625a..ccc54fd 100644 --- a/src/main/java/me/kavin/piped/utils/Multithreading.java +++ b/src/main/java/me/kavin/piped/utils/Multithreading.java @@ -1,13 +1,13 @@ package me.kavin.piped.utils; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.function.Supplier; public class Multithreading { - private static final ExecutorService es = Executors.newVirtualThreadPerTaskExecutor(); + private static final ExecutorService es = Executors.newCachedThreadPool(); private static final ExecutorService esLimited = Executors .newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 8); private static final ExecutorService esLimitedPubSub = Executors @@ -29,7 +29,7 @@ public class Multithreading { return es; } - public static CompletableFuture supplyAsync(Supplier supplier) { - return CompletableFuture.supplyAsync(supplier, es); + public static Future supplyAsync(Supplier supplier) { + return es.submit(supplier::get); } }