if (len > 0 && debug()) { log.debug ("PureAckAckSender: reviewing queue (" +len+ " msg" +(len==1? ")" : "s)")); }
  public void run()   {    int len;    while (true)     {      //  Wait until we have some new messages or we have timed out to       //  re-examine old messages.      synchronized (queue)       {        while (true)        {          //  Check for new messages before waiting.  They can come          //  in during waiting or during queue processing.          if (haveNewMessages)          {            haveNewMessages = false;            if (queue.size() > 0) break;          }          //  Check how long to wait before we need to satisfy a send deadline          long waitTime = 0;  // 0 = wait till notify (or interrupt)          if (queue.size() > 0)          {            waitTime = minSendDeadline - now();            if (waitTime <= 0) break;          }          //  Wait until timeout, notify, or interrupt          try { queue.wait (waitTime); } catch (Exception e) {}        }        messages = (PureAckAckMessage[]) queue.toArray (messages);  // try array reuse        len = queue.size();      }      //  Check if it is time to send a pure ack-ack message      minSendDeadline = Long.MAX_VALUE;      for (int i=0; i<len; i++)      {        PureAckAckMessage paam = messages[i];        PureAckAck pureAckAck = (PureAckAck) MessageUtils.getAck (paam);        String node = MessageUtils.getToAgentNode (paam);        long lastSendTime = MessageAckingAspect.getLastSendTime (node);        //  We sent at most one ack-ack, and then only if there has        //  not been any traffic back to the sending node since the        //  time we received a pure ack from it.        if (lastSendTime < pureAckAck.getReceiveTime())        {          long sendDeadline = pureAckAck.getSendDeadline();          long timeLeft = sendDeadline - now();          if (debug())          {             String m = MessageUtils.toShortString (paam);            log.debug ("PureAckAckSender: " +m+ " timeLeft="+timeLeft);          }          if (timeLeft <= 0)          {            //  Time to send the ack-ack            if (debug()) log.debug ("PureAckAckSender: Sending pure ack-ack " +paam);            remove (paam);  // remove first to avoid race condition with send            SendMessage.sendMsg (paam);          }          else           {            if (sendDeadline < minSendDeadline) minSendDeadline = sendDeadline;          }        }        else        {          if (debug()) log.debug ("PureAckAckSender: Dropping no longer needed pure ack-ack " +paam);          remove (paam);  // done sending this pure ack-ack message        }      }      Arrays.fill (messages, null);  // release references    }  }