Skip to main content
7 events
when toggle format what by license comment
Jan 13, 2015 at 19:17 comment added zgc7009 has only one thread in it -- if you tie up this thread indefinitely, none of your other tasks will run. Answered my question :)
Sep 4, 2014 at 12:17 comment added CommonsWare @eddy: TimerTask is from standard Java, not Android. TimerTask has largely been abandoned in favor of ScheduledExecutorService (which, despite its name, is as part of standard Java). Neither are tied to Android, and so you still need a service if you expect those things to run in the background. And, you really should consider AlarmManager, from Android, so you do not need a service hanging around just watching the clock tick.
Sep 4, 2014 at 12:13 comment added eddy Thank you @CommonsWare just the last question, does TimerTasks share the same disadvantages of AsyncTasks? or Is it a whole different thing?
Sep 4, 2014 at 12:08 comment added CommonsWare @eddy: Yes, as that does not change the nature of the thread pool. For a Service, just use a Thread or a ThreadPoolExecutor.
Sep 4, 2014 at 12:04 comment added eddy Is it the same even if I start the AsyncTask inside a Service?? I mean, would the long running operation still be a problem?
Oct 9, 2012 at 11:33 comment added baske Thanks for this explanation.. I could not find anything truly faulty about the use of AsyncTasks for long-running operations (although I usually delegate those to Services myself), but your argument on tie-ing up that ThreadPool (for which you can indeed make no assumptions about its size) seems spot-on. As a supplement to Anup's post about using a service: That service should itself also run the task on a background thread, and not block its own main thread. An option could be an IntentService, or, for more complex concurrency requirements, apply your own multithreading strategy.
Oct 9, 2012 at 11:00 history answered CommonsWare CC BY-SA 3.0