Revert to using a regular cached executor.

This commit is contained in:
Kavin 2023-03-18 18:52:04 +00:00
parent a56b13d290
commit 7b2ac41879
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD

View file

@ -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 <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier) {
return CompletableFuture.supplyAsync(supplier, es);
public static <U> Future<U> supplyAsync(Supplier<U> supplier) {
return es.submit(supplier::get);
}
}