diff --git a/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java b/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java index 9eae3af89..37d34a44f 100644 --- a/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java +++ b/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java @@ -44,6 +44,7 @@ import org.bukkit.block.data.BlockData; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; @@ -189,8 +190,13 @@ public interface EngineMantle extends IObjectPlacer { } PrecisionStopwatch p = PrecisionStopwatch.start(); - List post = Collections.synchronizedList(new KList<>()); - Consumer c = post::add; + KList post = new KList<>(); + Consumer c = (i) -> { + synchronized (post) + { + post.add(i); + } + }; int s = getRealRadius(); BurstExecutor burst = burst().burst(); @@ -205,7 +211,13 @@ public interface EngineMantle extends IObjectPlacer { } burst.complete(); - burst().burst(post); + + while(!post.isEmpty()) + { + KList px = post.copy(); + post.clear(); + burst().burst(px); + } } default void generateMantleComponent(int x, int z, MantleComponent c, Consumer post) { diff --git a/src/main/java/com/volmit/iris/util/parallel/BurstExecutor.java b/src/main/java/com/volmit/iris/util/parallel/BurstExecutor.java index 9129a0c3f..642e15f6c 100644 --- a/src/main/java/com/volmit/iris/util/parallel/BurstExecutor.java +++ b/src/main/java/com/volmit/iris/util/parallel/BurstExecutor.java @@ -45,7 +45,7 @@ public class BurstExecutor { public BurstExecutor queue(List r) { synchronized (futures) { - for (Runnable i : r) { + for (Runnable i : new KList<>(r)) { CompletableFuture c = CompletableFuture.runAsync(i, executor); futures.add(c); }