Multiple IntentService or one Service Multiple IntentService or one Service multithreading multithreading

Multiple IntentService or one Service


IntentService is just a convenient class to write services that are workers in the producer-consumer pattern. They are services designed to execute various tasks in a row and then stop. Services are not necessarily IntentServices such as services that must stay alive such as daemons.

So you should wonder if you service is close to a worker thread, if so, use IntentServices else just derive from Service.

Your second questions was whether to group all 3 services in a 3 in 1 service. The answer is that it depends how you use your datasources : if you use them altogether, then group them in a single service. If they are used separately, you could build a service for each with the hope to provide a lighter service if only one datasource is used and not the other. But if you use all 3 datasources, each in a service, then it will be heavier than using a single service.


Its my understanding that the difference between intentService and Service is that an intentService will spawn a worker thread to run it, while a Service runs in the main thread of it's hosting process. In addition, an intentService will stop itself when the work is done, while a Service will continue running until stopSelf, or stopService is called.

If the 3 data sources need to share information with each other, then put them all in the same Service, otherwise keep them separate because if one data source is down it will leave a fat service running instead of just a single light Service.


To allow multiple tasks to run at the same time off the main thread, you need to provide a managed collection of threads. Use a ThreadPoolExecutor to manage multiple threads at the same time:

http://developer.android.com/training/multiple-threads/create-threadpool.html