The Future interface doesn't provide a method for setting the result. In the docs, they say,
A Future represents the result of an asynchronous computation. Methods are provided to check if the computation is complete, to wait for its completion, and to retrieve the result of the computation.
But I don't understand how do I set the result in the first place?
I was comparing Future to DeferredResult from Spring and they both basically represent the result of Async computation but DeferredResult has method for setting the result and Future doesn't?
If you don't want to create your own class implementing Future and providing a setter (or extending FutureTask and making the setter public), you can use the ready-made CompletableFuture. It allows you to set the values, as well as a lot of other tricks that the Future interface doesn't show.