I'm using Needle; an open-source, simple and powerful multithreading library for Android. With it you can say things like:
Needle.onMainThread().execute(new Runnable() {
@Override
public void run() {
// e.g. change one of the views
}
});
or
Needle.onBackgroundThread().execute(new UiRelatedTask() {
@Override
protected Integer doWork() {
int result = 1+2;
return result;
}
@Override
protected void thenDoUiRelatedWork(Integer result) {
mSomeTextView.setText("result: " + result);
}
});
Pros
- very simple API
- fixed thread pool size
- customizable thread pool size
- supports UI interaction ("do work and then use result on UI thread")
- android 1.5+
- behaves the same on all platform versions
Cons
Check it out on GitHub: https://github.com/ZsoltSafrany/needle