-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[问答]Looper中的loop是如何实现阻塞的? #245
Comments
for (;;) {
if (nextPollTimeoutMillis != 0) {
Binder.flushPendingCommands();
}
nativePollOnce(ptr, nextPollTimeoutMillis);
//...
} 阻塞是发生在 Message被添加到队列中时,会根据 |
楼上说的很全,只补充一点,looper 本身就是为了解决ui的并发问题而使用的异步消息队列,通过不断的循环取消息然后通过 jni 分发到 native 方法进行处理 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
分析API22的源码,可以发现Loop操作如下
根据注释,我们可以知道
next
实现了阻塞,但是网上分析一般到这里就截止了,请问这里的Next是如何实现阻塞的呢?The text was updated successfully, but these errors were encountered: