bug修复: 修复PTT心跳线程池永久泄漏问题
This commit is contained in:
parent
397e103596
commit
8bddca4996
|
|
@ -28,6 +28,7 @@ public class CallBackResolution {
|
||||||
private static boolean loginState = false;
|
private static boolean loginState = false;
|
||||||
private static String pttLoginStatus = "00"; // 00-未登录 01-登录中 02-已登录
|
private static String pttLoginStatus = "00"; // 00-未登录 01-登录中 02-已登录
|
||||||
private static String pttLoginId = "";
|
private static String pttLoginId = "";
|
||||||
|
private static ScheduledExecutorService keepAliveExecutor = null;
|
||||||
|
|
||||||
public static String getPttLoginStatus() {
|
public static String getPttLoginStatus() {
|
||||||
return pttLoginStatus;
|
return pttLoginStatus;
|
||||||
|
|
@ -543,13 +544,16 @@ public class CallBackResolution {
|
||||||
if (tempTxt.contains("已登录")) {
|
if (tempTxt.contains("已登录")) {
|
||||||
String showName = tempTxt.substring(3, tempTxt.length());
|
String showName = tempTxt.substring(3, tempTxt.length());
|
||||||
CallBackUtil.callBackLogin(true, showName);
|
CallBackUtil.callBackLogin(true, showName);
|
||||||
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
if (keepAliveExecutor != null && !keepAliveExecutor.isShutdown()) {
|
||||||
|
keepAliveExecutor.shutdownNow();
|
||||||
|
}
|
||||||
|
keepAliveExecutor = Executors.newSingleThreadScheduledExecutor();
|
||||||
Runnable task = () -> {
|
Runnable task = () -> {
|
||||||
Timber.tag(TAG).d( "callBackLogin send tcp and udp");
|
Timber.tag(TAG).d( "callBackLogin send tcp and udp");
|
||||||
SendAtUtil.sendUDP();
|
SendAtUtil.sendUDP();
|
||||||
SendAtUtil.sendTCP();
|
SendAtUtil.sendTCP();
|
||||||
};
|
};
|
||||||
executor.scheduleAtFixedRate(task, 0, 40, TimeUnit.SECONDS);
|
keepAliveExecutor.scheduleAtFixedRate(task, 0, 40, TimeUnit.SECONDS);
|
||||||
} else if (tempTxt.contains("账号已更新")) {
|
} else if (tempTxt.contains("账号已更新")) {
|
||||||
Timber.tag(TAG).w("TTS reports account updated: '%s'", tempTxt);
|
Timber.tag(TAG).w("TTS reports account updated: '%s'", tempTxt);
|
||||||
} else if (tempTxt.contains("账号或密码错误")) {
|
} else if (tempTxt.contains("账号或密码错误")) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue