make it save every 10 seconds so its less laggy

This commit is contained in:
Chayapak 2023-06-29 16:23:30 +07:00
parent 075c3233d1
commit 321c7a50a3

View file

@ -44,17 +44,19 @@ public class PersistentDataUtilities {
e.printStackTrace(); e.printStackTrace();
} }
future = executor.scheduleAtFixedRate(PersistentDataUtilities::write, 0, 100, TimeUnit.MILLISECONDS); future = executor.scheduleAtFixedRate(PersistentDataUtilities::write, 0, 10, TimeUnit.SECONDS);
Runtime.getRuntime().addShutdownHook( Runtime.getRuntime().addShutdownHook(
new Thread(() -> { new Thread(() -> {
future.cancel(true); future.cancel(false);
write(); write();
}) })
); );
} }
// ? how do i clear the file contents without making a completely new FileWriter
// or is this the only way?
public static void write () { public static void write () {
try { try {
writer.close(); writer.close();