The Scala Promise
In this section, we will discuss the second component of the Scala Future API—Promise.
A Scala Promise is something similar to a Scala Future. Like a Scala Future, a Scala Promise may have a value or an exception. They have some minor differences in the actual functionality. Let's discuss them in the following sub-sections.
What is a Scala Promise?
Like a Scala Future, a Scala Promise is an object used to write AP. It is used to execute asynchronous code.
Like a Scala Future, a Scala Promise may have a value if it finishes successfully, or an exception or error if it finishes with some failure. We can say a Promise is completed if it finishes with a value or an exception. The following diagram defines what a Scala Promise is:

As we discussed, a Future is a placeholder to hold a computation unit (which returns a value or exception and does not yet exist). It is used to read that result, whereas a Promise is used to finish that computation and write a value into the Future.
So...