diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java index 5ee11aa9..da292949 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java @@ -18,7 +18,7 @@ public class PLaunchApp { public static JMinecraftVersionList.Version mVersion; public static boolean mIsAssetsProcessing = false; public static Thread[] assetThreads = new Thread[30]; - public static int assetThrIndex = -1; + public static int assetThrIndex = 0; public static void main(String[] args) throws Throwable { // User might remove the minecraft folder, this can cause crashes, safety re-create it @@ -183,7 +183,7 @@ public class PLaunchApp { Map assetsObjects = assets.objects; File objectsDir = new File(outputDir, "objects"); for (JAssetInfo asset : assetsObjects.values()) { - assetThreads[assetThrIndex++] = new Thread(() -> { + assetThreads[assetThrIndex] = new Thread(() -> { mIsAssetsProcessing = !UIKit.updateProgressSafe(currProgress / maxProgress, "Downloading " + assetsObjects.keySet().toArray(new String[0])[downloadedSs]); @@ -202,16 +202,19 @@ public class PLaunchApp { downloadedSs++; }); - - boolean isAllThreadsDone = false; - while (!isAllThreadsDone) { - isAllThreadsDone = true; - for (int i = 0; i < assetThreads.length; i++) { - Thread thr = assetThreads[i]; - isAllThreadsDone &= thr == null || !thr.isAlive(); - - if (thr != null && !thr.isAlive()) { - assetThreads[i] = null; + assetThreads[assetThrIndex].start(); + assetThrIndex++; + + if (assetThrIndex == assetThreads.length) { + boolean isAllThreadsDone = false; + while (!isAllThreadsDone) { + isAllThreadsDone = true; + for (int i = 0; i < assetThreads.length; i++) { + Thread thr = assetThreads[i]; + isAllThreadsDone &= thr == null || !thr.isAlive(); + if (thr != null && !thr.isAlive()) { + assetThreads[i] = null; + } } } }