android - How to spawn multiple threads for upload without waiting -


i have following class responsible fetch non synced receipts receipts table , upload them server, following function of iterates through cursor result set:

public class midnightupload {       public static void checklocalandupload(final context ctx) {          cursor cursor = databasehandler                 .getinstance(ctx)                 .getreadabledatabase()                 .query(receipt.table_name, receipt.fields,                         receipt.web_receipt_id + " ?", new string[]{"dummy"},                         null, null,                         null, null);          if (cursor != null && cursor.movetofirst()) {              {                 log.d("_id", cursor.getstring(cursor.getcolumnindexorthrow("_id")));                 log.d("receipt_id", cursor.getstring(cursor.getcolumnindexorthrow("receipt_id")));                 log.d("web_receipt_id", cursor.getstring(cursor.getcolumnindexorthrow("web_receipt_id")));                 log.d("receipt_name", cursor.getstring(cursor.getcolumnindexorthrow("receipt_name")));               //  log.d("image", cursor.getstring(cursor.getcolumnindexorthrow("image")));                 log.d("date_added", cursor.getstring(cursor.getcolumnindexorthrow("date_added")));                 log.d("status", cursor.getstring(cursor.getcolumnindexorthrow("status")));                 log.d("currency", cursor.getstring(cursor.getcolumnindexorthrow("currency")));                 log.d("category", cursor.getstring(cursor.getcolumnindexorthrow("category")));                 log.d("sub_category", cursor.getstring(cursor.getcolumnindexorthrow("sub_category")));                 log.d("payment", cursor.getstring(cursor.getcolumnindexorthrow("payment")));                 log.d("invoice", cursor.getstring(cursor.getcolumnindexorthrow("invoice")));                 log.d("custom_field", cursor.getstring(cursor.getcolumnindexorthrow("custom_field")));                 log.d("organization", cursor.getstring(cursor.getcolumnindexorthrow("organization")));                 log.d("person", cursor.getstring(cursor.getcolumnindexorthrow("person")));              } while (cursor.movetonext());         }       } } 

i aware can start multiple async tasks using:

 asynctask.executeonexecutor(asynctask.thread_pool_executor, params); 

the above method planning call intentservice. here confusions:

1) while loop wait till control has returned asynctask next iteration?

2)will using , spawning multiple threads within intentservice disrupt program?

3) better off using runnable r = new runnable() asynctask - dont intend ui operation?


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -