我猜广播消息是发到消息里的 接收线程的队列并通过循环器传递。广播是在消息队列中的其他消息之前传递的,还是只是附加到队列的末尾?我没有特别的需要或类似的东西,只是出于好奇想知道。
在服务和 Activity 之间使用 IPC 广播的性能开销(CPU 和内存)是多少?
GL
最佳答案
Are the broadcasts delivered before other messages in the message queue or just appended to the end of the queue?
我认为他们排在队列的末尾。测试这个的简单方法是 post()
几个 Runnables
到队列,每个 sleep 一会儿,然后给自己发送一个广播。如果Runnables
在广播前都处理完了,就到最后了。如果广播在后面的 Runnables
之前处理,那么它会在前面注入(inject)。
What is the performance overhead (CPU and memory) for using broadcasts for IPC between a service and an Activity?
适度,正如@jlindenbaum 所建议的那样。我不建议尝试启动成千上万的东西,并且有针对进程中工作的轻量级解决方案(例如,Messenger
)。
关于android - 广播传送和性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6863288/