android - Are separate intent services queued on the same thread? -


i have 2 intent services - intentservicea , intentserviceb

they have following class definitions:

public class firstservice extends intentservice {   public firstservice() {       super("first_service");   }    @override   protected void onhandleintent(intent intent) {       log.d("chi6rag", "first starts");       (long = 0l; < 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");       (long = 0l; < 10000000l; i++) {           if (i == 0l) log.d("chi6rag", "second started");       }       log.d("chi6rag", "second ends");   } } 

if execute following code in activity:

startservice(new intent(this, intentservicea.class)); startservice(new intent(this, intentserviceb.class));

i see following printed in 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 1 sees intent service docs, mentions passes one intent @ time onhandleintent method of intentservice

question: there separate worker thread each , every intent service? because 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

the intentservice following:

  1. creates default worker thread executes intents delivered onstartcommand() separate application's main thread.
  2. creates work queue passes 1 intent @ time onhandleintent() implementation, never have worry about
    multi-threading
  3. provides default implementation of onstartcommand() sends intent work queue , onhandleintent() implementation.

since have multiple classes extended form intentservice each has own specific onhandleintent. these handled on separate work queues.

see extending intentservice


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -