Home > Back-end >  For help, why method does not perform in the thread
For help, why method does not perform in the thread

Time:05-20

Thread A=new Thread (new Runnable () {
@ Override
Public void the run () {
Try {
System. The out. Println (" A -- -- -- -- -- ");
Code1 (startTime, endTime/2, SDF, timeMap);
}
The finally {
}
}
});


Thread C=new Thread (new Runnable () {
@ Override
Public void the run () {
Try {
System. The out. Println (" B -- -- -- -- -- ");
Code1 (endTime/2, endTime, SDF and timeMap);
} the finally {
}
}
});



A.s tart ();
C.s. tart ();


Code1:
Public void code1 (Long startTime, Long endTime, SimpleDateFormat SDF, Map & gt; TimeMap) {
For (Long I=startTime + 1000; I & lt;=endTime; I +=1000) {
//every second to query
//to put on a second data in
String dateOld=SDF. The format (new Date (I - 1000));
String date2=SDF. The format (new Date (I));
//now put on for a second data in a
TimeMap. Put (date2, timeMap. Get (dateOld));
Map CarStateVos=new HashMap<& gt; (a);
//now put on for a second data in a
CarStateVos. PutAll (timeMap. Get (date2));
/* LambdaQueryWrapper LambdaQ=Wrappers. LambdaQuery ();
LambdaQ. Eq (CarStateCai: : getUpdateTime, new Date (I));
List List1=enclosing a list (lambdaQ); */
Map map=new HashMap<& gt; (a);
The map. The put (" update_time ", new Date (I));
List List1.=carStateMapper selectByMap (map);
//whether the query data
//in this query without going to a in the
If (list1. The size () & gt; 0 {
For (CarStateCai CarStateCai: list1) {
If (carStateCai. GetCarNum ()!=null & amp; & !" ". The equals (carStateCai getCarNum ())) {
//read the information in the redis
The String value=https://bbs.csdn.net/topics/redisService.getValue (carStateCai getCarNum ());
CarStateDto carStateDto1=JSON. ParseObject (value, CarStateDto. Class);
CarStateVo CarStateVo=getCarStateVo (carStateDto1 carStateCai);
//if there will be overwritten
CarStateVos. Put (carStateVo. GetCarNum (), carStateVo);
}
}
String date1=SDF. The format (new Date (I));
System. The out. Println (date1 + "run");
TimeMap. Put (date1, carStateVos);
}
}
}
  • Related