• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multithreding issue in AsyncTask

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone!

I am trying to implement solution for stopping execution of methods inside doInBackground method. As far as I know, doInBackground executes in other thread so I am wondering if this will work everytime I try it to run. Is it possible that downloading second and third data will execute, because change of shouldDo flag will not be seen by doInBackground thread?

Here is simple code, which I wrote especially for this example:



When I run above code, it works as I expected. Clicking on the back button after "downloading first data..." log goes to onPostExecute immediately after finished current downloading.

Greetings,
MichaƂ Horowic


EDIT:

I will be very greatful for the answer if this above code will work every time I try it to run, but I solved this in this way (better, because I don't have to wait for end of current downloading):

reply
    Bookmark Topic Watch Topic
  • New Topic