JDeferred: Simple Handling of Promises and Futures

Published May 2017.

Developers are quite capable of dealing with events that occur serially. However, we struggle with parallel and delayed or deferred events. Fortunately, there are techniques
that can help to deal with delayed or deferred results. Principal among these techniques are promises and futures, which are the focus of this article, along with a library, JDeferred, that greatly simplifies their use.

Wikipedia defines the key concept behind them as an object that acts as a proxy for a result that’s initially unknown. A future is a read-only placeholder view of a variable; that is, its role is to contain a value and nothing more. A promise is a writable, single-assignment container that sets the value of the future. Promises may define an API that can be used to react to a future’s state changes, such as the value being resolved, the value being rejected due to an error (expected or unexpected), or the cancellation of the computing task. Let’s look at this in more detail.

Continue reading the rest of the article at the Oracle Java Magazine.

ˆ Back To Top