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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.