In this recipe, you learned how to use the Callable interface to launch concurrent tasks that return a result. You implemented the FactorialCalculator class that implements the Callable interface with Integer as the type of the result. Hence, the call() method returns an Integer value.
The other critical point of this example is the Main class. You sent a Callable object to be executed in an executor using the submit() method. This method receives a Callable object as a parameter and returns a Future object that you can use with two main objectives:
- You can control the status of the task you can cancel the task and check whether it has finished or not. For this purpose, you used the isDone() method.
- You can get the result ...