java - Does postDelayed cause the message to jump to the front of the queue? -


i looking on android docs postdelayed post delayed documentation

this similar question - https://stackoverflow.com/questions/25820528/is-postdelayed-relative-to-when-message-gets-on-the-queue-or-when-its-the-actual - had while different situation(and worded lot clearer in mind)

basically heres docs method - "causes runnable added message queue, run after specified amount of time elapses. runnable run on user interface thread."

i know every thread has message queue, looper , handler associated it. - what relationship between looper, handler , messagequeue in android?. in terms of "to run after specified amount of time elapses", if pass in 0 argument delaymillis , there still messages in message queue, message 0 skip on rest of messages(that in front of it) in message queue directly handled looper? know looper dispatch message handler's handlemessage() method- how looper knows send message handler?. test on own don't know how go it.

the short answer - no, doing postdelayed not jump in front of other non-delayed jobs in queue.

both post , postdelayed both call sendmessagedelayed, post uses delay of 0. thus, post , postdelayed 0 delay equivalent. (see handler source, starting around line 324). sendmessagedelayed states message in put in queue after pending requests. reason each message enqueued time enqueued plus optional delay. queue ordered time value. if enqueue new message no delay skip (be placed in front of) delayed messages still have not reached delivery time, not in front of pending messages (those past delivery time have yet delivered)

as side note, if want behavior request skips pending requests, can use postatfrontofqueue, sure read , understand warning used in special circumstances.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -