Processing results for Runnable objects in the Executor framework

The Executor framework allows the execution of concurrent tasks that returns a result using the Callable and Future interfaces. The traditional concurrent programming in Java is based on Runnable objects, but this kind of object doesn't return a result.

In this recipe, you will learn how to adapt a Runnable object to simulate a Callable one, allowing a concurrent task to return a result.

Get Java 9 Concurrency Cookbook - 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.