From 321c7a50a376362c9c97141a0a92af9c440c4250 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Thu, 29 Jun 2023 16:23:30 +0700 Subject: [PATCH] make it save every 10 seconds so its less laggy --- .../chayapak/chomens_bot/util/PersistentDataUtilities.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/PersistentDataUtilities.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/PersistentDataUtilities.java index 9f39357..894a290 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/PersistentDataUtilities.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/PersistentDataUtilities.java @@ -44,17 +44,19 @@ public class PersistentDataUtilities { e.printStackTrace(); } - future = executor.scheduleAtFixedRate(PersistentDataUtilities::write, 0, 100, TimeUnit.MILLISECONDS); + future = executor.scheduleAtFixedRate(PersistentDataUtilities::write, 0, 10, TimeUnit.SECONDS); Runtime.getRuntime().addShutdownHook( new Thread(() -> { - future.cancel(true); + future.cancel(false); write(); }) ); } + // ? how do i clear the file contents without making a completely new FileWriter + // or is this the only way? public static void write () { try { writer.close();