You can call execute(...) once on one instance of an AsyncTask. But you can create a new instance of an AsyncTask and call execute(...) on that new instance.
Multiple instances of an AsyncTask share a limited pool of threads. An AsyncTask instance is put into a queue when 'execute(...)' is called and a free thread in the pool will pick up this task and execute its 'execute(...)' method. On Apr 9, 3:20 pm, Jason LeBlanc <jasonalebl...@gmail.com> wrote: > Dianne, > > Thanks for the advice. AsyncTask seems to be a popular recommendation. For > some reason when I first read about it, I was turned away by the fact that > it could only be called once. I actually ordered a book on concurrency > yesterday, so hopefully I can get a better handle on multthreading. > > Mark, > > I took your advice and moved the Socket instantiation into the run() method. > Now it no longer locks up the UI thread. Thanks for that tidbit of wisdom. > > In the near future, I intend to create a small project to test the UI Thread > lockup from my splash screen. I'm still not sure why I couldn't thread the > start up of the service from the Activity and get the same results. > > Thanks, > J > > On Fri, Apr 9, 2010 at 12:54 PM, Dianne Hackborn <hack...@android.com>wrote: > > > > > I strongly recommend using IntentService, which takes care of the threading > > for you. Unless you are good at multithreading (I will claim that 90% of > > developers are not) then it is a good idea to stay away from Thread and use > > some higher-level facilities like IntentService, AsyncTask, etc. > > > On Fri, Apr 9, 2010 at 7:40 AM, Mark Murphy <mmur...@commonsware.com>wrote: > > >> Jason LeBlanc wrote: > >> > Yes, the Connection extends Thread. > > >> Then be sure not to do anything time-consuming in the Connection > >> constructor. Put the time-consuming stuff in run(). In this case, that > >> includes opening your socket connection, because while it might not be > >> time-consuming normally, it will be if it cannot resolve DNS, etc. > > >> > If I start a Thread in an Activity, does that Thread need to complete > >> > execution before I can transition to the next Activity? > > >> No. > > >> -- > >> Mark Murphy (a Commons Guy) > >>http://commonsware.com|http://twitter.com/commonsguy > > >> Warescription: Three Android Books, Plus Updates, One Low Price! > > >> -- > >> You received this message because you are subscribed to the Google > >> Groups "Android Developers" group. > >> To post to this group, send email to android-developers@googlegroups.com > >> To unsubscribe from this group, send email to > >> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > >> For more options, visit this group at > >>http://groups.google.com/group/android-developers?hl=en > > >> To unsubscribe, reply using "remove me" as the subject. > > > -- > > Dianne Hackborn > > Android framework engineer > > hack...@android.com > > > Note: please don't send private questions to me, as I don't have time to > > provide private support, and so won't reply to such e-mails. All such > > questions should be posted on public forums, where I and others can see and > > answer them. > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to android-developers@googlegroups.com > > To unsubscribe from this group, send email to > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en