remove shutdownhook

This commit is contained in:
Oliver 2020-06-15 00:28:37 +02:00
parent 112722d1c5
commit 1de6e05cfa
Signed by: okaestne
GPG Key ID: 06A81B143EA9588F
2 changed files with 19 additions and 32 deletions

View File

@ -72,7 +72,6 @@ public class AsyncHandler implements Runnable {
failed ++; failed ++;
if(failed > 10) if(failed > 10)
try { try {
Thread.yield();
Thread.sleep(1000);//wait 1 second Thread.sleep(1000);//wait 1 second
} catch(InterruptedException ignored) {} } catch(InterruptedException ignored) {}
//reenque //reenque

View File

@ -112,9 +112,6 @@ public class TelegramAPI implements Runnable {
} else { } else {
throw new IllegalStateException("Still Running."); throw new IllegalStateException("Still Running.");
} }
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
stop();
}, "TelegramAPI Shutdown Hook"));
} }
public void addAdmin(long admin) { public void addAdmin(long admin) {
@ -293,19 +290,10 @@ public class TelegramAPI implements Runnable {
public void stop() { public void stop() {
run = false; run = false;
log.log("tapi stoped.");
if(thread == null) return; if(thread == null) return;
thread.interrupt(); thread.interrupt();
Thread.yield();//try to not get into that loop
while(isRunning()) {
thread.interrupt();
Thread.yield();
try {
Thread.sleep(10);
} catch(InterruptedException e) {}
}
thread = null; thread = null;
log.log("TelegramAPI stoped.");
} }
@Override @Override