public int drainTo(Collection<? super E> c){
  int result=buffer.drainTo(c);
  if (producer != null) {
    producer.wakeUp();
  }
  return result;
}

public int drainTo ( Collection < ? super E > c ) { int result = buffer . drainTo ( c ) ; if ( producer != null ) { producer . wakeUp ( ) ; } return result ; }
removes all available elements from this queue and adds them to the given collection . this operation may be more efficient than repeatedly polling this queue . a failure encountered while attempting to add elements to collection c may result in elements being in neither , either or both collections when the associated exception is thrown . attempts to drain a queue to itself result in illegalargumentexception . further , the behavior of this operation is undefined if the specified collection is modified while the operation is in progress .
