我有一个ScheduledExecutorService,该事务已在事务中中断。我尝试在表中创建索引,以解决多个线程争用锁进行事务的问题,但问题仍然存在。有时会抛出异常,有时不会。我不知道哪个是第二个线程,对我来说只有一个,执行者服务(不包括主要服务)。
in the photo, the two threads paused in debugging
public void startExecutor() {
executor = Executors.newSingleThreadScheduledExecutor();
System.out.println("hilo ejecutandose");
Runnable updateTask = this::checkDate;
executor.scheduleWithFixedDelay(updateTask, INITIAL_DELAY, DELAY, TimeUnit.SECONDS);
}
public void checkDate() {
List<VersionConf> versions = this.versionConfDao.findByState(versionJdbcTemplate, 1);
if (versions.isEmpty()) {
LOGGER.debug("version in production not found");
} else {
String versionConf = versions.get(0).getDbname();
JdbcTemplate topologyConfTemplate = mapTcJdbcTemplate.get(versionConf);
List<CacheUpdate> lastUpdate = cacheUpdateDaoImpl.findAll(topologyConfTemplate);
/*HERE THREAD STOPS*/
...
}
public static void main(String [] args){ SpringApplication.run(ARSApplication.class);
}
//main class
@Override
public void run(String... args) throws Exception {
while (true) {
System.out.println("-------------------------------------");
Iterator<Shotpointelem> itkey = mapShotpoint.keySet().iterator();
while (itkey.hasNext()) {
Shotpointelem key = itkey.next();
List<Shotpoint> listShotpoint = mapShotpoint.get(key);
System.out.print("----" + key + "----");
for (Shotpoint shotpoint : listShotpoint) {
System.out.println("[" + key + "," + shotpoint + "]");
}
}
Thread.sleep(2000);
// this.shotpointLoader.startExecutor();
}