Пример #1
0
  public void run() {

    running = true;
    while (running) { // main loop

      for (Updateable updateable : updateables) {
        updateable.update();
      }

      // sleep a bit
      try {
        Thread.sleep(MAIN_LOOP_SLEEP);
      } catch (InterruptedException iex) {
      }
    }

    getContext().stopping();

    // close everything:
    getContext().getAccountsService().saveAccounts(true);
    NatHelpServer natHelpServer = getContext().getService(NatHelpServer.class);
    if ((natHelpServer != null) && natHelpServer.isRunning()) {
      natHelpServer.stopServer();
    }

    // add server notification:
    ServerNotification sn = new ServerNotification("Server stopped");
    sn.addLine("Server has just been stopped gracefully. See server log for more info.");
    getContext().getServerNotifications().addNotification(sn);

    LOG.info("Server closed gracefully!");

    getContext().stopped();
  }
Пример #2
0
 @Override
 public void update() {
   for (Updateable u : this) {
     u.update();
   }
 }
  @Override
  protected void loop() throws InterruptedException {
    updateable.update();

    Thread.sleep(delayTime);
  }