runOnUiThread() method for Android

android, multithreading

Solution

I suppose you would say the method is `start()`:

new Thread() {
  public void run() {
    // do something
  }
}.start();

or use `AsyncTask` or some `Executor` from `java.util.concurrent` or whatever.

Problem

I'm used to calling runOnUiThread() to ensure that a block of code gets run, well, on the UI thread. I would like the same ease to launch a block of code off the UI thread. What should that method look like?

Original source