code: public synchronized int clear() {
      final int count = taskQueue.size();
      for (final TaskEntity task : taskQueue) {
        canceledTasks.add(task);
      }
      taskQueue.clear();
      return count;
    }
docs: Clear the pending list.
  @return the number of removed tasks