【发布时间】:2015-01-30 03:28:04
【问题描述】:
我正在查看有关 postDelayed 的 Android 文档 post delayed documentation
这类似于另一个问题 - https://stackoverflow.com/questions/25820528/is-postdelayed-relative-to-when-message-gets-on-the-queue-or-when-its-the-actual - 我有一段时间了,但情况不同(并且在我的脑海中措辞更加清晰)
基本上这是文档对这个方法所说的 - “导致 Runnable 被添加到消息队列中,在指定的时间过去后运行。runnable 将在用户界面线程上运行。”
我知道每个线程都有一个与之关联的消息队列、循环器和处理程序。 -What is the relationship between Looper, Handler and MessageQueue in Android?。 就“经过指定的时间后运行”而言,如果您将 0 作为 delayMillis 的参数传入并且消息队列中仍有消息,那么带有 0 的消息是否会跳过其余消息(即目前在它前面)在Message Queue中由looper直接处理?我知道 looper 会将消息从How the Looper knows to send the message to Handler? 发送到处理程序的handleMessage() 方法。我会自己测试这个,但我真的不知道你会怎么做。
【问题讨论】:
标签: java android multithreading handler