ScheduledExecutorService прервана в транзакции - PullRequest
0 голосов
/ 07 марта 2019

У меня есть ScheduledExecutorService, который был прерван в транзакции.Я попытался создать индекс в своей таблице, чтобы решить проблему, когда несколько потоков борются за блокировку для выполнения транзакции, но проблема все еще остается.Иногда исключение брошено, а иногда нет.Я не знаю, какой второй поток, для меня есть только один, служба исполнителя (основной не входит).

на фотографии, два потока приостановлены в отладке

  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();
    }
...