We have a web application that needs to import 10-20 images from a partner site via http. If I have a list of strings that represent the urls I want to download does anybody have a suggestion for how to download them as fast as possible?
I could just put them in a for loop but if there is a simple way to parallelize this it would be probably be good for the end user. I would like to avoid using straight Java threads, although the executor framework might be a good idea.
Any ideas?
The Executor framework is EXACTLY what you want. Specifically the ExecutorCompletionService. Using this, you’ll be able to submit requests quickly and in any order. Then you’ll retrieve them exactly as they completed (as opposed to submission order).