Reputation: 40356
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?
Upvotes: 4
Views: 516
Reputation: 76564
An alternative to ASyncTask
new Thread(){
public void run() {
// Do something
};
}.start();
Upvotes: 3
Reputation: 1007554
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.
Upvotes: 9
Reputation: 1666
You most likely want an AsyncTask
. Refer to this article: http://developer.android.com/resources/articles/painless-threading.html
Upvotes: 3