A Future is something which doesn’t have a value at current time however can come later in future. It is an abstraction provided by Scala to deal with concurrency and threads easily and effectively.

val f = Future(3)
 
f.value.get.get // 3

Methods

Future provides helping methods such as

  • onComplete
  • foreach
  • etc.

onComplete and foreach method are called once the future is completed. The difference between them is that foreach is called only when the future is succeeded.