public void run(){
  try {
    boolean cleanRemoteSessions=false;
synchronized (this) {
      Collection<StateInfo> infos=new ArrayList<>();
      infos.addAll(servers.values());
      infos.addAll(sites.values());
      for (      StateInfo info : infos) {
        info.isUp=checkServerUp(info);
        if (!info.isUp) {
          down.add(info.id);
        }
 else {
          if (!down.isEmpty() && down.remove(info.id)) {
            cleanRemoteSessions=true;
          }
        }
      }
    }
    if (cleanRemoteSessions) {
      foreignSessionHandler.cleanUpRemoteSessions();
    }
  }
 catch (  Exception ex) {
    sessionDebug.error("cleanRemoteSessions Background thread has encountered an Exception: " + ex.getMessage(),ex);
  }
}

public void run ( ) { try { boolean cleanRemoteSessions = false ; synchronized ( this ) { Collection < StateInfo > infos = new ArrayList < > ( ) ; infos . addAll ( servers . values ( ) ) ; infos . addAll ( sites . values ( ) ) ; for ( StateInfo info : infos ) { info . isUp = checkServerUp ( info ) ; if ( ! info . isUp ) { down . add ( info . id ) ; } else { if ( ! down . isEmpty ( ) && down . remove ( info . id ) ) { cleanRemoteSessions = true ; } } } } if ( cleanRemoteSessions ) { foreignSessionHandler . cleanUpRemoteSessions ( ) ; } } catch ( Exception ex ) { sessionDebug . error ( "cleanRemoteSessions Background thread has encountered an Exception: " + ex . getMessage ( ) , ex ) ; } }
monitoring logic used by background thread
