Is it possible to have a service with multiple threads in it? How to achieve this?
you can't have more than one thread in a service.
you can create multiple threads in a service.
option 2 is possible by creating thread in onCreate().
option 2 is possible by creating thread in onStartCommand() of your service class.
Services are possible with single thread and multiple threads also. If you want multi threaded service, then write thread creation logic in onStartCommand() because this function will be called every time some one starts the service. if you want single threaded service then create thread in onCreate() of service class. Multi threaded services are also possible with AsyncTasks.
Back To Top