CancellationFlag

Inheritance: java.lang.Object

All Implemented Interfaces: java.lang.AutoCloseable

public class CancellationFlag implements AutoCloseable

The flag that allows for the cancellation of operations.

Constructors

ConstructorDescription
CancellationFlag()Constructs a CancellationFlag instance.

Methods

MethodDescription
cancel()Cancels the operation associated with this CancellationFlag instance.
cancelAfter(long delay)Cancels the operation after a specified delay in milliseconds.
cancelAfter(long delay, TimeUnit unit)Cancels the operation after a specified delay in the given time unit.
close()Closes the CancellationFlag instance and releases any resources associated with it.

CancellationFlag()

public CancellationFlag()

Constructs a CancellationFlag instance.

cancel()

public void cancel()

Cancels the operation associated with this CancellationFlag instance.

If the operation is already cancelled, this method does nothing.

cancelAfter(long delay)

public void cancelAfter(long delay)

Cancels the operation after a specified delay in milliseconds.

Parameters:

ParameterTypeDescription
delaylongThe delay in milliseconds after which the operation will be cancelled.

cancelAfter(long delay, TimeUnit unit)

public void cancelAfter(long delay, TimeUnit unit)

Cancels the operation after a specified delay in the given time unit.

Parameters:

ParameterTypeDescription
delaylongThe delay after which the operation will be cancelled.
unitjava.util.concurrent.TimeUnitThe time unit of the delay parameter.

close()

public void close()

Closes the CancellationFlag instance and releases any resources associated with it.