14.3.3 Cancelling Operation

You can cancel a pending request by invoking the cancel method of the returned PgxFuture instance.

For example:

PgxFuture<Object> promise=...
// do something else
promise.cancel(); // will cancel computation

Any subsequent calls to promise.get() will result in a CancellationException being thrown.

Note:

Due to Java's cooperative threading model, it might take some time before PGX actually stops the computation.