If a thread blocks, for example, a thread waiting for an I/O operation to complete, this is wasteful. The following diagram shows a thread using a blocking API call for getting a response from a web service over the network. The sequential execution model needs to wait as the flow cannot proceed otherwise. On the other hand, asynchronous execution does not block the calling thread. A future is used for expressing such asynchronous computations. The following diagram shows how it works:
As shown, a future is a placeholder. It will eventually contain the response or can timeout if the call takes too long to complete.
How does the calling thread work with the future though?