Handler原理时序图
2021-09-22 21:04:46 19 举报
Handler原理时序图
作者其他创作
大纲/内容
ThreadLocal
cb.handleMessage()
Looper.loop()
new MessageQueue()
msg
Looper.prepareMainLooper();
MessageQueue
prepare(false);
ActivityThread
Handler
mHandler.sendMessage(msg)
Thread
sendMessageDelayed
Looper.myLooper()
Looper
new Looper()
enqueueMessagemsg.target=this;
msg.target.dispatchMessage(msg)
mQueue
main()
new Handler(cb)
dispatchMessage(msg)
queue.next()
handleMessage()
mHandler
此处取消息,需要一直循环获取,如果还没到达时间,就休眠,还有一个同步屏障的概念需要注意
HandlerActivity
sendMessageAtTime
sThreadLocal.get()
mThread = Thread.currentThread()
sThreadLocal.set(Looper)
mLooper、mQueue
0 条评论
下一页