title: DelayQueue unexpected behavior. DrainTo deletes from the queue only 1 expired item
body: <p>I want to iterate through unexpired elements in my DelayQueue.
  The class Transaction implements Delayed, and has a field timestamp, which represents the timestamp of a transaction when it was originated in UTC (not the current timestamp)</p>
  
  <pre><code>public class Transaction implements Delayed {
      private final Double amount;
      private final Long timestamp;   //timestamp of a time when the item was created and send here
  
  
      public Transaction(double amount, long timestamp) {
          this.amount = amount;
          this.timestamp = timestamp;
      }
  
      @Override
      public long getDelay(TimeUnit unit) {
          long delay = unit.convert(ONEMINUTE - (System.currentTimeMillis() - timestamp), TimeUnit.MILLISECONDS);
      return delay;
  }
  
      @Override
      public int compareTo(Delayed delayed) {
          if (delayed == this) {
              return 0;
          }
  
          if (delayed instanceof Transaction) {
              return 0;
          }
  
          long diff = (getDelay(TimeUnit.MILLISECONDS) - delayed.getDelay(TimeUnit.MILLISECONDS));
          return ((diff == 0) ? 0 : ((diff &lt; 0) ? -1 : 1));
      }
  
      @Override
      public int hashCode() {
          final int prime = 31;
          int result = 1;
          result = prime * result + timestamp.hashCode();
          return result;
      }
  
      @Override
      public boolean equals( Object obj ) {
          if( this == obj ) {
              return true;
          }
  
          if( obj == null ) {
              return false;
          }
  
          if( !( obj instanceof Transaction ) ) {
              return false;
          }
  
          final Transaction other = ( Transaction )obj;
          return timestamp.equals(other.timestamp);
      }
  }
  </code></pre>
  
  <p>The TransactionManager class below adds the incoming transaction to the queue, if the new coming transaction is younger than 1 minute.
  On getStatistics, the old transactions should be removed from the queue, and the queue should contain only transactions younger then 1 minute</p>
  
  <pre><code>public class TransactionManager {
  
      private DelayQueue&lt;Transaction&gt; transactions;
  
  
      public TransactionManager() {
          transactions = new DelayQueue&lt;&gt;();
          System.setProperty("user.timezone", "UTC");
      }
  
      public Object createTransaction(String json) {
          JSONObject jsonObject = null;
          try {
              jsonObject = JsonValidator.validateTransactionJson(json);
          } catch (Exception ex) {
              return new ResponseEntity(HttpStatus.UNPROCESSABLE_ENTITY);
          }
          long delay = System.currentTimeMillis() - ((Long) jsonObject.get(TIMESTAMP));
          if (delay &gt; ONEMINUTE) {
              return new ResponseEntity(HttpStatus.NO_CONTENT);
          }
          transactions.add(new Transaction((Double) jsonObject.get(AMOUNT), (Long) jsonObject.get(TIMESTAMP)));
          return new ResponseEntity(HttpStatus.OK);
      }
  
      public long getStatistics() {
          List&lt;Transaction&gt; tempForCleaning = new ArrayList&lt;&gt;();
          transactions.drainTo(tempForCleaning);
          tempForCleaning.clear();
          StatisticJSON statistics = new StatisticJSON();
          transactions.stream().forEach(transaction -&gt; {
              statistics.setCount(statistics.getCount() + 1);
          });
          return statistics.getCount();
      }
  }
  </code></pre>
  
  <p>In this test I create 5 transactions with the time of 40 seconds before now, and 3 transactions of 10 seconds before now.
  So after waiting 45 seconds, the first 5 should be drained, and the queue should contain only 3 transaction, however, the method drainTo removes only 1 old transaction. </p>
  
  <pre><code>@Test
  public void test() {
      DateTime dateTime = new DateTime(DateTimeZone.UTC);
      long fortyMilliSecondsAgo = dateTime.minusSeconds(40).getMillis();
      long twentyMilliSecondsAgo = dateTime.minusSeconds(10).getMillis();
      for (int i = 0; i &lt; 5; i++) {
          createTransaction(fortyMilliSecondsAgo);
      }
      for (int i = 0; i &lt; 3; i++) {
          createTransaction(twentyMilliSecondsAgo);
      }
      Assert.assertTrue(transactionManager.getStatistics() == 8);
      try {
          TimeUnit.SECONDS.sleep(45);
          System.out.println("\n\n\n");
          Assert.assertTrue(transactionManager.getStatistics() == 3);
      } catch (InterruptedException e) {
          e.printStackTrace();
      }
  }
  
  private void createTransaction(long timestamp) {
      transactionManager.createTransaction("{\"amount\":100.0,\"timestamp\":" + timestamp + "}");
  }
  </code></pre>
  
  <p>I'm missing something, why drainTo removes only one expired item, even there is 4 left, but cannot catch where...</p>