Fixed crash when exit

This commit is contained in:
2025-04-25 23:52:37 +02:00
parent 486232623a
commit 32c1391336
@@ -117,17 +117,22 @@ public class Auth {
private static void startPingThread() { private static void startPingThread() {
pingThread = new Thread(() -> { pingThread = new Thread(() -> {
try { try {
while (running) { while (running && !Thread.currentThread().isInterrupted()) {
try {
Thread.sleep(25000); // 25 seconds Thread.sleep(25000); // 25 seconds
if (running) { if (running) {
Network.write("ping"); Network.write("ping");
} }
}
} catch (InterruptedException e) { } catch (InterruptedException e) {
SaturnClient.LOGGER.warn("Ping thread interrupted", e); Thread.currentThread().interrupt(); // Restore interrupt status
break; // Exit the loop on interruption
}
}
} catch (Exception e) { } catch (Exception e) {
if (!(e instanceof InterruptedException)) {
SaturnClient.LOGGER.error("Error in ping thread", e); SaturnClient.LOGGER.error("Error in ping thread", e);
} }
}
}); });
pingThread.setDaemon(true); pingThread.setDaemon(true);