From 85ee7e4d42c286489488e3f455bac7a7ad657029 Mon Sep 17 00:00:00 2001 From: M*C*O Date: Tue, 30 Apr 2024 16:56:29 +0000 Subject: [PATCH] constrain multi-downloader to 1-12 threads --- src/main/java/com/sheepit/client/Client.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sheepit/client/Client.java b/src/main/java/com/sheepit/client/Client.java index 7521a14..eab0e6d 100644 --- a/src/main/java/com/sheepit/client/Client.java +++ b/src/main/java/com/sheepit/client/Client.java @@ -784,8 +784,9 @@ import okhttp3.HttpUrl; protected Error.Type downloadSceneFile(Job ajob_) throws SheepItException { int total = ajob_.getArchiveChunks().size(); + int threads = Math.max(1, Math.min(total, 12)); // at least one thread, to avoid IllegalArgumentException if total = 0 - ExecutorService executor = Executors.newFixedThreadPool(total); + ExecutorService executor = Executors.newFixedThreadPool(threads); ArrayList> tasks = new ArrayList<>(); this.gui.getDownloadProgress().reset("Downloading project");