TiGer
TiGer

Reputation: 5949

Question regarding a specific "difference" between Service and IntentService

We have been testing a little bit with Service and IntentServices in Android. As far as we understood one of the benefits of the IntentService is it's own thread and worker queue... After testing we noticed that if you send a 100 intents to both services they will both start executing sequentially...

Thats somewhat expected form the IntentService because of it's worker queue, but how does Android behave regarding to several request to a non-multithreaded Service ? Cause it seems like it has some kind of underlying worker queue as well ? Or maybe some kind of Intents-queue which is kept by the Android system itself ? And if so, is there any way to attach to it, for example to see it's length/size ?

Upvotes: 1

Views: 644

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006604

but how does Android behave regarding to several request to a non-multithreaded Service ?

Calls to startService() are queued in the message queue for the main application thread of the sender, just like calls to any GUI operation (e.g., setText()), calls to startActivity(), and so on.

IntentService has a second queue, inside the service itself, for received Intents to be processed by the background thread.

Upvotes: 3

Related Questions