Created
August 17, 2017 21:34
-
-
Save anonymous/a904ce79adedc1941788a43f87f0c54f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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