title: Running futures sequentially
body: <p>The objective of the code below is to execute Future <code>f3</code> or <code>f4</code> depending on a condition. Note that the condition depends on the result of Future <code>f1</code> or <code>f2</code>, so it has to wait. This seems to work, however since <code>f1</code> and <code>f2</code> are futures this code shouldn't run sequentially. Is this code correct?</p>
  
  <pre><code>object TestFutures extends App {
  
    val f1 = Future { 1 }
    val f2 = Future { 2 }
    val f3 = Future { 3 }
    val f4 = Future { 4 }
  
    val y = 1
  
    for {
      condition &lt;- if (y&gt;0) f1 else f2
      _ &lt;- if (condition==1) f3.map {a =&gt; println("333")} else f4.map {b =&gt; println("444")}
    }  yield ()
  
  
    Thread.sleep(5000)
  }
  </code></pre>