日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Hanlder Looper MessageQueue Message

發布時間:2024/4/14 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Hanlder Looper MessageQueue Message 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Handler:處理消息

Message:消息

MessageQueue:消息隊列

Looper:MessageQueue的管理者

?

MessageQueue:

? 消息隊列。以先進先出的原則存放多個Message.MessageQueue是通過Handler進行管理,通過Looper.Prepare()創建Looper的同時會自動創建MessageQueue對象.UI主線程默認會創建Looper,其他線程需要手動創建.通過Looper. Prepare()和Looper. Looper.loop(),對MessageQueue進行循環處理。

?

Message:

? 消息對象。new Message().obtain()得到Message,如果Message Pool中已經有Message對象則總Pool獲取,沒有則創建一個新的Message對象。也可以同過new Message()創建一個新的對象。

?

Looper:

? Looper是MessageQueue的管理者,創建Looper對象就會創建MessageQueue,MessageQueu脫離不了Looper.除了UI主線程會創建一個默認的Looper,其他線程都要通過Looper.prepare()方法創建。Looper遵循先進先出的原則,循環從MessageQueue中讀取Message。

? Looper從MessageQueue中取出消息后交給Handler().handleMessage(msg)處理,處理完成調用Message().recycle() 放入到Message Pool中.

?

Handler:

? 負責處理消息。Handler將消息封裝成Message,通過new Message().obtainMessage()創建一個Message,也可以通過Message message = new Message()創建消息。Handler().obtainMessage()方法如果Message Pool中已經有Message對象,則直接調用該對象,不用每次創建一個對象

。將消息傳遞給Looper,調用Handler().sendMessage(msg)時,Looper將Message加入到MessageQueue.繼而Looper通過廣播的形式將消息發送出去,Hanlder通過Handler().obtainMessage()方法接受到消息,做相應處理.

轉載于:https://www.cnblogs.com/webview/p/4226687.html

總結

以上是生活随笔為你收集整理的Hanlder Looper MessageQueue Message的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。