mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-03-30 21:05:58 -05:00
Fix java.lang.IllegalArgumentException in ThreadingUtils
Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
@@ -58,7 +58,7 @@ public class ThreadingUtils {
|
||||
|
||||
public static void run(Collection<UnsafeRunnable> jobs) {
|
||||
try {
|
||||
ExecutorService service = Executors.newFixedThreadPool(Math.min(jobs.size(), Runtime.getRuntime().availableProcessors() / 2));
|
||||
ExecutorService service = Executors.newFixedThreadPool(Math.max(1, Math.min(jobs.size(), Runtime.getRuntime().availableProcessors())));
|
||||
List<Future<?>> futures = new LinkedList<>();
|
||||
|
||||
for (UnsafeRunnable runnable : jobs) {
|
||||
@@ -94,7 +94,7 @@ public class ThreadingUtils {
|
||||
|
||||
public static <T> List<T> get(Collection<UnsafeCallable<T>> jobs) {
|
||||
try {
|
||||
ExecutorService service = Executors.newFixedThreadPool(Math.min(jobs.size(), Runtime.getRuntime().availableProcessors() / 2));
|
||||
ExecutorService service = Executors.newFixedThreadPool(Math.max(1, Math.min(jobs.size(), Runtime.getRuntime().availableProcessors())));
|
||||
List<Future<T>> futures = new LinkedList<>();
|
||||
List<T> result = new ArrayList<>();
|
||||
|
||||
@@ -138,7 +138,7 @@ public class ThreadingUtils {
|
||||
public static class TaskCompleter implements Function<Throwable, Void> {
|
||||
Stopwatch stopwatch = Stopwatch.createUnstarted();
|
||||
List<CompletableFuture<?>> tasks = new ArrayList<>();
|
||||
ExecutorService service = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
||||
ExecutorService service = Executors.newFixedThreadPool(Math.max(1, Runtime.getRuntime().availableProcessors()));
|
||||
List<UnsafeConsumer<Stopwatch>> completionListener = new ArrayList<>();
|
||||
|
||||
public TaskCompleter add(UnsafeRunnable job) {
|
||||
|
||||
Reference in New Issue
Block a user