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 ++;
if(failed > 10)
try {
Thread.yield();
Thread.sleep(1000);//wait 1 second
} catch(InterruptedException ignored) {}
//reenque

View File

@ -112,9 +112,6 @@ public class TelegramAPI implements Runnable {
} else {
throw new IllegalStateException("Still Running.");
}
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
stop();
}, "TelegramAPI Shutdown Hook"));
}
public void addAdmin(long admin) {
@ -293,19 +290,10 @@ public class TelegramAPI implements Runnable {
public void stop() {
run = false;
log.log("tapi stoped.");
if(thread == null) return;
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;
log.log("TelegramAPI stoped.");
}
@Override