code: public void flushAll(boolean waitForAllToFinish) {
          Log.v(Log.TAG_BATCHER, "%s: flushing all objects (wait=%b)", this, waitForAllToFinish);
  
          synchronized (mutex) {
              isFlushing = true;
              unschedule();
          }
  
          while (true) {
              ScheduledFuture future = null;
              synchronized (mutex) {
                  if (inbox.size() == 0)
                      break; // Nothing to do
  
                  final List<T> toProcess = new ArrayList<T>(inbox);
                  inbox.clear();
                  mutex.notifyAll();
                  synchronized (workExecutor) {
                      if (!workExecutor.isShutdown()) {
                          future = workExecutor.schedule(new Runnable() {
                              @Override
                              public void run() {
                                  processor.process(toProcess);
                                  synchronized (mutex) {
                                      lastProcessedTime = System.currentTimeMillis();
                                  }
                              }
                          }, 0, TimeUnit.MILLISECONDS);
                      }
                  }
              }
  
              if (waitForAllToFinish) {
                  if (future != null && !future.isDone() && !future.isCancelled()) {
                      try {
                          future.get();
                      } catch (Exception e) {
                          Log.e(Log.TAG_BATCHER, "%s: Error while waiting for pending future " +
                                  "when flushing all items", e, this);
                      }
                  }
              }
          }
  
          synchronized (mutex) {
              isFlushing = false;
          }
      }
docs: Sends _all_ the queued objects at once to the processor block.
  After this method returns, all inbox objects will be processed.
  
  @param waitForAllToFinish wait until all objects are processed. If set to True,
  need to make sure not to call flushAll in the same
  WorkExecutor used by the batcher as it will result to
  deadlock.