-
public class CancellationTokenPropagates notification that operations should be canceled.
Create an instance of
{@code CancellationTokenSource}and pass the token returned from{@code * CancellationTokenSource#getToken()}to the asynchronous operation(s). Call{@code * CancellationTokenSource#cancel()}to cancel the operations.A
{@code CancellationToken}can only be cancelled once - it should not be passed to future operations once cancelled.
-
-
Method Summary
Modifier and Type Method Description booleanisCancellationRequested()CancellationTokenRegistrationregister(Runnable action)Registers a runnable that will be called when this CancellationToken is canceled. voidthrowIfCancellationRequested()StringtoString()-
-
Method Detail
-
isCancellationRequested
boolean isCancellationRequested()
-
register
CancellationTokenRegistration register(Runnable action)
Registers a runnable that will be called when this CancellationToken is canceled. If this tokenis already in the canceled state, the runnable will be run immediately and synchronously.
- Parameters:
action- the runnable to be run when the token is cancelled.
-
throwIfCancellationRequested
void throwIfCancellationRequested()
-
-
-
-