CancellationFlag
Contents
[
Hide
]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
Constructor | Description |
---|---|
CancellationFlag() | Constructs a CancellationFlag instance. |
Methods
Method | Description |
---|---|
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:
Parameter | Type | Description |
---|---|---|
delay | long | The 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:
Parameter | Type | Description |
---|---|---|
delay | long | The delay after which the operation will be cancelled. |
unit | java.util.concurrent.TimeUnit | The time unit of the delay parameter. |
close()
public void close()
Closes the CancellationFlag instance and releases any resources associated with it.