Skip to content

Instantly share code, notes, and snippets.

Created August 17, 2017 21:34
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 anonymous/a904ce79adedc1941788a43f87f0c54f to your computer and use it in GitHub Desktop.
Save anonymous/a904ce79adedc1941788a43f87f0c54f to your computer and use it in GitHub Desktop.
import scala.concurrent.Future
object FutureStuff extends App {
import scala.concurrent.ExecutionContext.Implicits.global
val f1 = Future{
Thread.sleep(10000)
println("HI1")
1
}
val f2 = Future{
Thread.sleep(3000)
println("HI2")
2
}
val f3 = Future{
Thread.sleep(1000)
println("HI3")
3
}
val future = for {
v1 <- f1
v2 <- f2
v3 <- f3
} yield (v1, v2, v3)
future.onSuccess {
case (_, _, _) => println(s"DONE!")
}
Thread.sleep(15000)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment