title: Asynchronous IO in Scala with futures
body: <p>Let's say I'm getting a (potentially big) list of images to download from some URLs. I'm using Scala, so what I would do is :</p>
  
  <pre><code>import scala.actors.Futures._
  
  // Retrieve URLs from somewhere
  val urls: List[String] = ...
  
  // Download image (blocking operation)
  val fimages: List[Future[...]] = urls.map (url =&gt; future { download url })
  
  // Do something (display) when complete
  fimages.foreach (_.foreach (display _))
  </code></pre>
  
  <p>I'm a bit new to Scala, so this still looks a little like magic to me :</p>
  
  <ul>
  <li>Is this the right way to do it? Any alternatives if it is not?</li>
  <li>If I have 100 images to download, will this create 100 threads at once, or will it use a thread pool?</li>
  <li>Will the last instruction (<code>display _</code>) be executed on the main thread, and if not, how can I make sure it is?</li>
  </ul>
  
  <p>Thanks for your advice!</p>