multithreading - android call url in for loop -


i calling url inside for:each using new thread.start.
data getting uploaded, threads executing in parallel.
want call url in series depending on status of previous url. there inbuilt functionality in android call url in series.

this current code:

for(item : foodlist) {       if(i.issection()) {            sectionitem item= (sectionitem) i;       } else {            food f= (food) i;            upload(f.getfoodid(),                 string.valueof(f.getcalories()),                f.getquantity(),                f.getunit()           );       }  } 

thanks in advance

you can implement queue - run next operation when current finished, suggest several things:

1) don't use threads data upload directly, face troubles approach.

2) use services 'long' operations.

3) check this rest implementation in android.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -