O'Reilly logo

Mastering Concurrency Programming with Java 9 - Second Edition by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required