From 5ac51dd2a5fd24be6203d22004a760ad9d696fa6 Mon Sep 17 00:00:00 2001 From: tom lee Date: Fri, 7 Jan 2022 13:28:12 +0800 Subject: [PATCH] Fixed accidentally using java 9+ features. Now java 7 should work --- .../lod/core/handlers/LodDimensionFileHandler.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/seibel/lod/core/handlers/LodDimensionFileHandler.java b/src/main/java/com/seibel/lod/core/handlers/LodDimensionFileHandler.java index a2ddc873a..9f943430c 100644 --- a/src/main/java/com/seibel/lod/core/handlers/LodDimensionFileHandler.java +++ b/src/main/java/com/seibel/lod/core/handlers/LodDimensionFileHandler.java @@ -264,7 +264,10 @@ public class LodDimensionFileHandler if (regionToSave.isEmpty()) return; // Use Memory order Acquire to acquire any memory changes on getting this boolean // (Corresponding call is the this::writerMain(...)::...setRelease(false);) - boolean haventStarted = !isFileWritingThreadRunning.compareAndExchangeAcquire(false, true); + //boolean haventStarted = !isFileWritingThreadRunning.compareAndExchangeAcquire(false, true); + // The above needs java 9! + boolean haventStarted = !isFileWritingThreadRunning.compareAndSet(false, true); + if (haventStarted) { // We acquired the atomic lock. fileWritingThreadPool.execute(this::writerMain); @@ -274,7 +277,10 @@ public class LodDimensionFileHandler private void writerMain() { // Use Memory order Relaxed as no additional memory changes needed to be visible. // (This is just a safety checks) - boolean isStarted = isFileWritingThreadRunning.getPlain(); + // boolean isStarted = isFileWritingThreadRunning.getPlain(); + // The above needs java 9! + boolean isStarted = isFileWritingThreadRunning.get(); + if (!isStarted) throw new ConcurrentModificationException("WriterMain Triggered but the thead state is not started!?"); ClientApi.LOGGER.info("Lod File Writer started. To-be-written-regions: "+regionToSave.size()); Instant start = Instant.now(); @@ -303,7 +309,9 @@ public class LodDimensionFileHandler ClientApi.LOGGER.info("Lod File Writer completed. Took "+Duration.between(start, end)); // Use Memory order Release to release any memory changes on setting this boolean // (Corresponding call is the this::saveRegions(...)::...compareAndExchangeAcquire(false, true);) - isFileWritingThreadRunning.setRelease(false); + // isFileWritingThreadRunning.setRelease(false); + // The above needs java 9! + isFileWritingThreadRunning.set(false); } /**