code: public boolean runOnMainThread(final Runnable r) {
          assert handler != null;
          if (!sanityCheck("runOnMainThread " + r)) {
              return false;
          }
  
          Runnable wrapper =  new Runnable() {
              public void run() {
                  FPSCounter.timeCheck("runOnMainThread <START> " + r);
                  r.run();
                  FPSCounter.timeCheck("runOnMainThread <END> " + r);
              }
          };
  
          if (isMainThread()) {
              wrapper.run();
              return true;
          } else {
              return runOnMainThreadNext(wrapper);
          }
      }
docs: Executes a {@link Runnable} on the main thread. If this method is called
  from the main thread, the {@code Runnable} will be executed immediately;
  otherwise, it will be {@linkplain Handler#post(Runnable) posted} to the
  {@link Looper Looper's} message queue.
  
  @param r
  The {@link Runnable} to run on the main thread.
  @return Returns {@code true} if the Runnable was either immediately
  executed or successfully placed in the Looper's message queue.