我@async在spring-boot应用程序中使用 java注释来处理和上传 excel 文件。即使我大致同时上传多个文件,它也能正常工作。但是,我想知道我实现的以下代码是否是线程安全的。我的理解是它不是,它可能会失败。我无法重现并发问题
我的代码:
while (rowIterator.hasNext()) {
Row row=rowIterator.next();
if(row.getRowNum()==0)
continue;
BatchScript script=new BatchScript();
String rtId=row.getCell(0).toString();
String query=row.getCell(1).toString();
String agent=row.getCell(2).toString();
script.setRtId(rtId);
script.setQuery(query);
script.setAgentName(agent);
}
在代码中 BatchScript 是我的 POJO 类。你能告诉我它是否会失败吗?
BIG阳
ibeautiful
相关分类