Futures end only at the end of the asynchronous calculation:
val f: Future[List[Int]] = Future {
makeSomeNumbers()
}
f onSuccess {
case foo => println("I was completed when makeSomeNumbers finished")
}
Promises , .
val p = Promise[String]()
val f = p.future
p success('hi') //when success is called, the Future is completed.
f onSuccess {
case foo => println("I was completed because a Promise told me to do so")
}
, onSuccess, , , - . Promises success .