Reputation: 6178
Once an AsyncTask call is finished is the thread deleted?
I stored an AsyncTask in a var "guiThread = (GUIAsyncTask) new GUIAsyncTask()". The first call to execute() works but subsequent calls don't. So, do I just create new tasks whenever I need them? I was under the impression that I used my variable over and over and calling new over and over would spin up thousands/millions of threads.
Upvotes: 1
Views: 305
Reputation: 7708
Nope you need to create a new AyncTask everytime you want to use it.
Upvotes: 1
Reputation: 36035
AsyncTasks
are one-time uses. They start, execute, then die. Then you have a choice of keeping the reference around to gather information from it that may be stored in the class post-execute, or dumping the reference and letting the garbage collector handle it. If you want to start the AsyncTask
again, you have to create a new object and start it.
Upvotes: 3