System.err.println ("PureAckSender: Launching " +pam);
  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          // System.err.println ("\nPureAckSender: WAIT waitTime= "+waitTime);          CougaarThread.wait (queue, waitTime);          // System.err.println ("\nPureAckSender: RUN");        }        messages = (PureAckMessage[]) queue.toArray (messages);  // try array reuse        len = queue.size();//System.err.println ("PureAckSender: len="+len);      }      //  Check if it is time to send a pure ack message      minSendDeadline = Long.MAX_VALUE;      for (int i=0; i<len; i++)      {        //  We only consider sending a pure ack message as long as there is        //  a need to send an ack for the src message we received that created        //  this pure ack message.  If that is no longer the case, we can        //  drop this pure ack message.        PureAckMessage pam = messages[i];//System.err.println ("PureAckSender: msg="+MessageUtils.toString(pam));        if (MessageAckingAspect.findAckToSend (pam))        {          PureAck pureAck = (PureAck) MessageUtils.getAck (pam);          long sendDeadline = pureAck.getSendDeadline();          long timeLeft = sendDeadline - now();          if (MessageAckingAspect.debug)          {            String m = MessageUtils.toShortString (pam);//          System.err.println ("PureAckSender: "+m+": timeLeft="+timeLeft);          }          if (timeLeft <= 0)          {            //  Time to send/resend the ack            if (MessageAckingAspect.debug)             {//            System.err.println ("PureAckSender: Launching " +pam);            }            remove (pam);  // remove first to avoid race condition with send            MessageSender.sendMsg (pam);          }          else           {            if (sendDeadline < minSendDeadline) minSendDeadline = sendDeadline;          }        }        else        {          // System.err.println ("PureAckSender: removing " +pam);          remove (pam);  // done sending this pure ack message        }      }      Arrays.fill (messages, null);  // release references    }  }