如果我们考虑效率,是否可以跟随?
new Runnable() {
@Override
public void run() {
try {
final Runnable uitask = new Runnable() {
public void run() {
//sth that modifies UI
}
};
for (...) {
context.runOnUiThread(uitask);
Thread.sleep(...);
}
} catch (Throwable t) {
}
}
}
我最担心 runOnUi 可能每次都会创建新线程,这会很糟糕吗?我是对的还是它像 ThreadPool 一样聪明?