Future objects in Scala

As we mentioned before, a Future stores a value that doesn't exist yet, but will be available at some point in the future. This value will be calculated by an asynchronous task that will be executed by another thread. Most of the time, you will specify that task when you define the Future and the task will be scheduled for its execution that can begin anytime in the future.

Futures don't use a blocking mechanism to get their result. You can associate one or more callback functions that will be executed when the Future has a value or an exception occurs during its process.

Futures have two possible return values. If the task ends its execution without errors and returns a value, we say that the Future has been successfully ...

Get Mastering Concurrency Programming with Java 9 - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.