13
My application uses a Service to do some background stuff. I am using additional threads in the service to do some computation. For this purpose I create two threads every 5 to 10 seconds, which are running 5 to 10 seconds. But I don't know which thread-model I should use:
AsyncTask:
Pros:
- easy to use
- android specific
- easy UI-interaction
Cons:
- Since I have to use API level 10, there is no
ExecutorServicewith fixed thread pool to execute the AsyncTasks
Normal Java Threads:
Pros:
- ExecutorService with fixed thread pool
Cons:
- Not so easy to handle, e.g. UI-interaction
Which model is better to use? Especially in concern of performance. Is there a heavy overhead when i am using AsyncTasks, and is the ExecutorService faster in reusing the threads than Android in creating new AsyncTasks?