private static ConcurrentMap<String, MqttMsgBean> comSendTaskList=new
ConcurrentHashMap<>();
private void closeSendTh(){
if(sendThread !=null){
sendState = false;
sendThread=null;
}
}
private void initSendTask(MqttMsgBean event){
comSendTaskList.put(event.api_name,event);
}
private Thread sendThread;
private boolean sendState=true;
private void initSendTimer(){
if(sendThread != null){return;}
sendThread=new Thread(new Runnable() {
@Override
public void run() {
try {
while (sendState){
if(comSendTaskList !=null && comSendTaskList.size() > 0){
for(Map.Entry<String, MqttMsgBean> entry: comSendTaskList.entrySet()){
MqttMsgBean event =entry.getValue();
// switch (event.type){
// case EventCode.CMD_0A0C:
//// handEvent_0A0C(event);//借开门
// break;
// case EventCode.CMD_0A06://关门断电(结束订单)
//// handEvent_0A06(event);
// break;
// default:break;
// }
if (event.type%2==0){
LgqLogutil.e("偶数=------ "+event.type);
}else {
LgqLogutil.e("奇数。。。。=------ "+event.type);
}
comSendTaskList.remove(entry.getKey());
SystemClock.sleep(800);
}
}
// SystemClock.sleep(1500);
}
}catch (Exception e){
}
}
});
sendThread.start();
}
MqttMsgBean mqttMsgBean = new MqttMsgBean();
mqttMsgBean.type=3424;
mqttMsgBean.api_name=4324+"bb";
initSendTask(mqttMsgBean);