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