Multithread background executor using Guava

We have a bunch of audio files that must be downloaded from a remote site and stored locally. After all the downloads have completed, we must persist data about the local files inside a db.

This routine uses a pool of threads (Guava ListeningExecutorService) to perform in parallel the downloads. Each download is expressed as a Future where the string, once returned, will contain data about the local file. Each download is entrusted to a thread from the pool and the corresponding Future is added to a List<Future>.

If you’re still here, you may well wish to read the whole lot

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s