How does Android sendMessageAtTime() really work?

894 Views Asked by At

So I have an large (up to 5000) array of pre-defined, time-senstive messages I want my program to send to a Handler. Some of these messages need to be as little as 40 milliseconds apart. I thought I could just call a bunch of sendMessageAtTime() to queue them up and my Handler would be called for each one at the appropriate time.

Unfortunately, at least in my AVD, it appears to execute the handler a few times then not do anything until the last message is sent. Is the Handler not keeping up? (i.e. can't finish before the next time it's called?)

Does sendMessageAtTime() wait to send the message until the Handler is done with its current message?

What happens if the specified time to send the message is in the past? Does it drop the message entirely or does it send it before sending any other "later" messages in the queue?

Are there any techniques to make the Handler "keep up"? For example, I could include the requested time in the message to the Handler so that the Handler could do nothing if it determines it's too late.

Thanks.

0

There are 0 best solutions below