if (n <= 0 || !servicesReady()) { return; }
  private void sendQueuedAlerts() {    int n;    List l;    // Publish new ThreatAlerts    synchronized (sendQueue) {      n = sendQueue.size();      if (n <= 0 || !servicesReady()) {        return;      }      l = new ArrayList(sendQueue);      sendQueue.clear();    }    for (int i = 0; i < n; i++) {      RelayAdapter ra = (RelayAdapter)l.get(i);      blackboard.publishAdd(l.get(i));      myRelays.put(ra.getUID(), ra);      if (log.isDebugEnabled()) {        log.debug("publishAdd ThreatAlert Relay: " + ra);      }      if (ra.getTargets().contains(agentId)) {        addThreatAlert((ThreatAlert)ra.getContent());        if (log.isDebugEnabled()) {          log.debug("add ThreatAlert locally: " + ra);        }      }    }    // Publish updated ThreatAlerts    synchronized (updateQueue) {      n = updateQueue.size();      if (n <= 0 || !servicesReady()) {        return;      }      l = new ArrayList(updateQueue);      updateQueue.clear();    }    for (int i = 0; i < n; i++) {      RelayAdapter ra = (RelayAdapter)l.get(i);      blackboard.publishChange(l.get(i));      if (log.isDebugEnabled()) {        log.debug("publishChange ThreatAlert: " + ra);      }      if (ra.getTargets().contains(agentId)) {        fireListenersForChangedAlert((ThreatAlert)ra.getContent());      }    }    // Process canceled ThreatAlerts    synchronized (cancelQueue) {      n = cancelQueue.size();      if (n <= 0 || !servicesReady()) {        return;      }      l = new ArrayList(cancelQueue);      cancelQueue.clear();    }    for (int i = 0; i < n; i++) {      cancelThreatAlert((ThreatAlert)l.get(i));    }  }