public class CancellationToken
extends java.lang.Object
CancellationTokenSource
and pass the token returned from
CancellationTokenSource#getToken()
to the asynchronous operation(s).
Call CancellationTokenSource#cancel()
to cancel the operations.
A CancellationToken
can only be cancelled once - it should not be passed to future operations
once cancelled.Modifier and Type | Method and Description |
---|---|
boolean |
isCancellationRequested() |
void |
throwIfCancellationRequested() |
java.lang.String |
toString() |
public boolean isCancellationRequested()
true
if the cancellation was requested from the source, false
otherwise.public void throwIfCancellationRequested() throws java.util.concurrent.CancellationException
java.util.concurrent.CancellationException
- if this token has had cancellation requested.
May be used to stop execution of a thread or runnable.public java.lang.String toString()
toString
in class java.lang.Object