I am trying to do specific task in a separate thread in android using Thread Pool executor with the Max thread size of 5 making sure there can be five parallel task would be run at a time. But problem with this approach is When I close my application the thread will also be killed. I want this to run out of application scope. I could have opted for service with the AIDL . But problem with this is I need to keep on bind and unbind to the service and I need to parcel the object before I need to send it. Also when the task is completed i need to communicate back to the calling application. This I could any how achieve using Broadcast. I was wondering If I can make a thread run in a separate process or I need to go with AIDL only ? Please help me understand!
A thread is, by definition, part of an application. Then, it's not possible to have a thread outside an app.
When you have an app that never creates nor uses new threads, you're running a main thread, that uses the full CPU time assigned by the OS to the app.
Since this, your options are:
1) To leave your app running in background and connect to it.
2) To use the service way.
Hope this help you to understand.