【发布时间】:2015-08-11 00:19:14
【问题描述】:
当我有一个在 onHandleIntent 完成之前被多次调用的 intentService 时,在 android 中会发生什么。让我给你举个例子:
假设我有一个如下所示的意图服务:
public class AService extends IntentService {
public AService() {
super("AService");
}
@Override
protected void onHandleIntent(Intent intent) {
// magic happens here but lets pretend it takes 3 mins.
}
}
现在假设我多次调用此服务,请求是否排队?并发是如何处理的,或者我希望通过在 onHandleIntent 中放置一个同步块来处理它,如下所示:
synchronized (AService.class) {
//do stuff here
}
【问题讨论】:
标签: android android-intentservice