for(Iterator>> iterator = cursorMap.entrySet().iterator();iterator.hasNext();){
final Entry> entry = (Entry>)iterator.next();
final String fileName = entry.getValue().get("fileName")+".cursor";
logger.info(entry.getValue().get("fileName")+" etl start");
scheduleServiceMap.get(entry.getValue().get("fileName")).scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
LongCursor cursor = null;
try {
Entry> cursorEntry = entry;
read(fileName);
} catch (Throwable e) {
}
}
}, 0, delay, TimeUnit.MILLISECONDS);
}
这样 entry和fileName是否线程安全,我想要达到一个线程一个entry和fileName。我跟人是觉得没问题,可是程序跑出来异常。