67,513
社区成员
发帖
与我相关
我的任务
分享
Timer timer1 = new Timer();
Timer timer2 = new Timer();
EntryTimerControl entryTimerControl = new EntryTimerControl();
OutTimerControl outTimerControl = new OutTimerControl();
timer1.schedule(entryTimerControl, 200, 3000);
timer2.schedule(outTimerControl, 500, 3000);
public void run() {
try {
log.info("启动进校定时扫描.....");
try {
String[] str = timeAreaEarly.split("-"); // 进
long l = new Date().getTime() / 1000; // 当前时间
long d = sf.parse(sf1.format(new Date()) + str[0]).getTime() / 1000; // 清空时间
int c = (int) (l - d);
if (c > 0 && c < 20) { // 初始化数据
submitMap.clear();
log.info("内存数据:" + submitMap.size() + " 队列大小:"
+ EnterCardProcessor.queue.size());
}
} catch (ParseException e) {
log.error("时间格式转换异常...", e);
}
Collection<Card> collection = new ArrayList<Card>();
EnterCardProcessor.queue.drainTo(collection);
for (final Card card : collection) { // 所有队列数据出队
newFixedThreadPool.execute(new Runnable() {
@Override
public void run() {
sendMessage(card);
}
});
}
} catch (Exception e) {
log.error("进校数据处理异常...", e);
} finally{
log.info("结束进校定时扫描.");
}
}