3

right now i am uploading image in single thread using asynctask. but it is not efficient and it's takes lot of time to upload. so i am refering this link to download image using ThreadPoolExecuter. can i use this strategy while uploading image also ?

is this good practice to upload image?

mcd
  • 1,434
  • 15
  • 31

2 Answers2

2

is this good practice to upload image?

YES that could be an option if you don't worry about tracking of each execution (i.e when thread completed its task ).

See what google doc says

they usually provide improved performance when executing large numbers of asynchronous tasks, due to reduced per-task invocation overhead, and they provide a means of bounding and managing the resources, including threads, consumed when executing a collection of tasks.

dharmendra
  • 7,835
  • 5
  • 38
  • 71
0

You can down- as well as up-load an image in a separate thread, that's perfectly fine.

If you want to use several threads for that, it would make no sense due to limited bandwidth (several threads would not speed-up the process) and partitioning issues (on the server).

injecteer
  • 20,038
  • 4
  • 45
  • 89
  • so according to you . there is no need to create multiple Thread for it. single Background Thread using IntentService Solve This issue even if there is and more than 50 images ?? – mcd May 28 '14 at 13:47
  • 1
    The critical factor here is the IO bandwidth. Even with HSDPA (LTE is not everywhere available) you can upload 1 image at a time. So, even if you create and start 50 threads for 50 images, they all get queued (due to IO-locking), which returns us effectively to 1 thread per 50 images. You can also use `Loaders` from the google doc link you posted – injecteer May 28 '14 at 13:54
  • 1
    I would completely disagree with this assessment. Depending on the nature/size/compression of the image, multithreaded upload may speed things up 2-10x. It is rare that your IO is slower than your network. (currently I am uploading >50,000 120MB images to s3, and threading really speeds things up) More evidence [here](http://improve.dk/pushing-the-limits-of-amazon-s3-upload-performance/) – meawoppl Jun 06 '14 at 17:28
  • so, did this speed the things up? – injecteer Jun 10 '14 at 07:38
  • yup i try it on my Project And It Works Radically Fast . – mcd Jun 11 '14 at 04:54