code: public static void stopThread(Handler handler, boolean asap) {
          Runnable stopper = sStopper;
          if (stopper == null) {
              stopper = new ThreadUtils();
              sStopper = stopper;
          }
  
          if (asap) {
              handler.postAtFrontOfQueue(stopper);
          } else {
              handler.post(stopper);
          }
      }
docs: Post the {@link Runnable} instance with the following code to the {@link Handler} provided:
  <pre>
  public void run() {
  Looper.myLooper().quit();
  }
  </pre>
  
  @param handler target handler, can not be null
  @param asap    if true then method {@link Handler#postAtFrontOfQueue(Runnable)} will be used.