解决一台设备同时存在两个线程获取性能数据

master
yineng.huang 2024-07-12 11:43:15 +08:00
parent e38f18a050
commit c2b8a98a2c
1 changed files with 16 additions and 14 deletions

View File

@ -118,25 +118,27 @@ public class AndroidDebuggerServiceImpl extends AbstractDebuggerService {
@Override
public boolean recordDevicePer(DebuggerDeviceInfo info) {
AndroidDeviceInfoByPackageThread androidDeviceInfoByPackageThread = queryDeviceInfoByPackageMap.get(info.getCaseId());
if (androidDeviceInfoByPackageThread == null || !androidDeviceInfoByPackageThread.isAlive() || androidDeviceInfoByPackageThread.isInterrupted()) {
logger.debug("开始记录任务【{}】的应用的参数。。。。。。。。。。", info.getCaseId());
androidDeviceInfoByPackageThread = new AndroidDeviceInfoByPackageThread(info);
androidDeviceInfoByPackageThread.start();
queryDeviceInfoByPackageMap.put(info.getCaseId(), androidDeviceInfoByPackageThread);
AndroidDeviceInfoByPackageThread androidDeviceInfoByPackageThread = queryDeviceInfoByPackageMap.get(info.getDeviceId());
if (androidDeviceInfoByPackageThread != null) {
logger.debug("记录设备【{}】的应用的性能在任务【{}】中已经存在,干掉上一个。。。。。。。。。。", info.getDeviceId(),info.getCaseId());
androidDeviceInfoByPackageThread.stopThread();
} else {
logger.debug("记录任务【{}】的应用的参数线程已经存在,无需创建新的。。。。。。。。。。", info.getCaseId());
logger.debug("记录设备【{}】的应用的性能线程不存在。。。。。。。。。。", info.getDeviceId());
}
logger.debug("开始记录设备【{}】任务【{}】的应用的参数。。。。。。。。。。", info.getDeviceId(),info.getCaseId());
androidDeviceInfoByPackageThread = new AndroidDeviceInfoByPackageThread(info);
androidDeviceInfoByPackageThread.start();
queryDeviceInfoByPackageMap.put(info.getDeviceId(), androidDeviceInfoByPackageThread);
AndroidDeviceAllInfoThread androidDeviceAllInfoThread = queryDeviceInfoMap.get(info.getCaseId());
if (androidDeviceAllInfoThread == null || !androidDeviceAllInfoThread.isAlive() || androidDeviceAllInfoThread.isInterrupted()) {
logger.debug("开始记录任务【{}】的设备的参数。。。。。。。。。。", info.getCaseId());
androidDeviceAllInfoThread = new AndroidDeviceAllInfoThread(info);
androidDeviceAllInfoThread.start();
queryDeviceInfoMap.put(info.getCaseId(), androidDeviceAllInfoThread);
if (androidDeviceAllInfoThread != null ) {
logger.debug("记录设备【{}】的性能数据,任务【{}】已经存在。。。。。。。。。。", info.getDeviceId(),info.getCaseId());
androidDeviceAllInfoThread.stopThread();
} else {
logger.debug("记录任务【{}】的设备的参数线程已经存在,无需创建新的。。。。。。。。。。", info.getCaseId());
logger.debug("记录设备【{}】性能线程不存在。。。。。。。。。。", info.getDeviceId());
}
androidDeviceAllInfoThread = new AndroidDeviceAllInfoThread(info);
androidDeviceAllInfoThread.start();
queryDeviceInfoMap.put(info.getCaseId(), androidDeviceAllInfoThread);
return true;
}