来自不同线程调用的onCreate同时 [英] calling onCreate from different threads at the same time

查看:125
本文介绍了来自不同线程调用的onCreate同时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读Android文档在一张code是onCreate方法内同步的同步适配器
AFAIK的Andr​​oid只能创建一个服务的一个实例的话,可以使用Android在同一时间从不同的线程调用的onCreate?或者是它可以调用的onCreate前一个服务方法已经完成(使用AIDL)?

I have read Android documentation in which a piece of code is synchronized inside the onCreate method, Sync Adapter. AFAIK Android only creates one instance of a Service so, can Android call onCreate from different threads at the same time? or is it possible to call a Service method before onCreate has finished (using AIDL)?

推荐答案

您链接到文件(关于一个线程安全的方式创建 SyncAdapter )是没有意义的。 的onCreate() A 服务只会被调用在主线程,所以不存在这种可能性,这ISN ŧ线程安全的。

The documentation you linked to (regarding creating SyncAdapter in a thread-safe manner) makes no sense. onCreate() of a Service is only ever called on the main thread, so there is no possibility that this isn't thread-safe.

此外,你不能打电话之前使用AIDL任何方法的onCreate()完成,因为你首先需要绑定到服务,你不能绑定到服务直到的onCreate()完成。

Also, you cannot call any methods using AIDL before the onCreate() completes, because you would first need to bind to the Service, and you can't bind to the Service until onCreate() completes.

这篇关于来自不同线程调用的onCreate同时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆