synchronized (deliveryLock)
try
   void cancelAllDeliveries() throws JMSException   {      synchronized (deliveryLock)      {               if (log.isTraceEnabled()) { log.trace(this + " cancels deliveries"); }                  //Need to cancel starting at the end of the list and working to the front         //in order that the messages end up back in the correct order in the channel                  for (int i = deliveries.size() - 1; i >= 0; i--)         {               SingleReceiverDelivery d = (SingleReceiverDelivery)deliveries.get(i);            try            {               boolean cancelled = d.cancel();               if (!cancelled)               {                  throw new JMSException("Failed to cancel delivery:" + d.getReference().getMessageID());               }                              if (log.isTraceEnabled()) { log.trace(d +  " canceled"); }            }            catch(Throwable t)            {               log.error("Cannot cancel delivery: " + d, t);            }                     }         deliveries.clear();      }      promptDelivery();   }