remove shutdownhook
This commit is contained in:
parent
112722d1c5
commit
1de6e05cfa
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue