Fixed crash when exit
This commit is contained in:
@@ -117,16 +117,21 @@ 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()) {
|
||||||
Thread.sleep(25000); // 25 seconds
|
try {
|
||||||
if (running) {
|
Thread.sleep(25000); // 25 seconds
|
||||||
Network.write("ping");
|
if (running) {
|
||||||
|
Network.write("ping");
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt(); // Restore interrupt status
|
||||||
|
break; // Exit the loop on interruption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
|
||||||
SaturnClient.LOGGER.warn("Ping thread interrupted", e);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Error in ping thread", e);
|
if (!(e instanceof InterruptedException)) {
|
||||||
|
SaturnClient.LOGGER.error("Error in ping thread", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user