【发布时间】:2012-11-06 17:07:53
【问题描述】:
我基本上是在做此消息底部的代码发布。 foobar() 将事件发布到公共状态机中。 我还将触摸屏事件发布到公共状态机中。 是真的,通过使用处理程序我没有同步问题吗? (即,我的状态机不会同时通过触摸事件和 foobar 事件发送消息)?
private Handler handler = new Handler();
handler.postDelayed(runnable, 100);
private Runnable runnable = new Runnable() {
@Override
public void run() {
/* do what you need to do */
foobar();
/* and here comes the "trick" */
handler.postDelayed(this, 100);
}
};
【问题讨论】:
标签: android multithreading timer handler state-machine