Exemplo n.º 1
0
  public void run() {

    log.debug("run() start");

    boolean loop = true;

    int queueSize = IdentifyQueue.getInstance().size();
    log.info("Trying to Sending item to Protex Server - Identify Queue Size: " + queueSize);

    long startTime = System.currentTimeMillis();
    while (loop) { // block

      BackgroundJobManager.getInstance().requestStopIdentifyThread();

      long endTime = System.currentTimeMillis();
      long timeDuration = endTime - startTime;

      if (timeDuration % 100 == 0) System.out.println("delayTime : " + timeDuration);

      if (timeDuration >= TIME_LIMIT) {
        log.error("TIME_LIMIT_EXCEED during completing sending items to Protex server ");
        loop = false;
        aDialogDiaplayerThread.closeDialog();
        String exitMessage =
            "OSI fails to sync with Protex Server.\n"
                + "Please contact to OSI Development Team to resolve this problem.";
        String[] button = {"OK"};
        JOptionPane.showOptionDialog( // block
            null,
            exitMessage,
            "Exit",
            JOptionPane.YES_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            button,
            "OK");
        continue;

      } else {

        boolean isAllidentifyThreadStopped =
            BackgroundJobManager.getInstance().isAllIdentifyThreadReadyStatus();
        if (isAllidentifyThreadStopped) {
          queueSize = IdentifyQueue.getInstance().size();
          log.info(
              "OSI succeeds to sync with Protex Server. - Identify Queue Size: "
                  + queueSize
                  + " / "
                  + timeDuration
                  + " ms.");
          loop = false;
          aDialogDiaplayerThread.closeDialog();
        }
      }

      try {
        Thread.sleep(100);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
    log.debug("run() end");
  }