Skip to content

Instantly share code, notes, and snippets.

@vijaykiran
Created November 4, 2015 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijaykiran/5915a5c482be18b4252a to your computer and use it in GitHub Desktop.
Save vijaykiran/5915a5c482be18b4252a to your computer and use it in GitHub Desktop.
import scala.concurrent._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
object Futs {
def stuff() = {
val fut1 = Future {
println("future 1")
1
}
val fut2 = Future {
println("future 2")
throw new RuntimeException("OMG, ponies")
}
val fut3: Future[Int] = Future {
println("future 3")
3
}
val thing = for {
one <- fut1
two <- fut2
three <- fut3
} yield one + two + three
println(Await.result(thing, 5.seconds))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment