I have two intent services - IntentServiceA
and IntentServiceB
They have the following class definitions:
public class FirstService extends IntentService {
public FirstService() {
super("first_service");
}
@Override
protected void onHandleIntent(Intent intent) {
Log.d("chi6rag", "first starts");
for (long i = 0l; i < 10000000l; i++) {
if (i == 0l) Log.d("chi6rag", "first started");
}
Log.d("chi6rag", "first ends");
}
}
and
public class SecondService extends IntentService {
public SecondService() {
super("second_service");
}
@Override
protected void onHandleIntent(Intent intent) {
Log.d("chi6rag", "second starts");
for (long i = 0l; i < 10000000l; i++) {
if (i == 0l) Log.d("chi6rag", "second started");
}
Log.d("chi6rag", "second ends");
}
}
If I execute the following code in my Activity:
startService(new Intent(this, IntentServiceA.class));
startService(new Intent(this, IntentServiceB.class));
I see the following printed in my logs:
D/chi6rag (11734): first starts
D/chi6rag (11734): first started
D/chi6rag (11734): second starts
D/chi6rag (11734): second started
D/chi6rag (11734): first ends
D/chi6rag (11734): second ends
While if one sees the Intent Service Docs, it clearly mentions that it passes one intent at a time
to onHandleIntent
method of the IntentService
Question: Is there a separate worker thread for each and every intent service? because the expected logs are:
D/chi6rag (11734): first starts
D/chi6rag (11734): first started
D/chi6rag (11734): first ends
D/chi6rag (11734): second starts
D/chi6rag (11734): second started
D/chi6rag (11734): second ends