code: public final void drain() {
      do {
        if (!drainingThread.compareAndSet(null, Thread.currentThread())) {
          return;
        }
        try {
          Runnable runnable;
          while ((runnable = queue.poll()) != null) {
            try {
              runnable.run();
            } catch (Throwable t) {
              uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), t);
            }
          }
        } finally {
          drainingThread.set(null);
        }
        // must check queue again here to catch any added prior to clearing drainingThread
      } while (!queue.isEmpty());
    }
docs: Run all tasks in the queue in the current thread, if no other thread is running this method.
  Otherwise do nothing.
  
  <p>Upon returning, it guarantees that all tasks submitted by {@code #executeLater} before it
  have been or will eventually be run, while not requiring any more calls to {@code drain()}.