Class CancellationFlag

  • All Implemented Interfaces:
    AutoCloseable

    public class CancellationFlag
    extends Object
    implements AutoCloseable
    The flag that allows for the cancellation of operations.
    • Constructor Detail

      • CancellationFlag

        public CancellationFlag()
        Constructs a CancellationFlag instance.
    • Method Detail

      • cancel

        public void cancel()
        Cancels the operation associated with this CancellationFlag instance.

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

      • cancelAfter

        public void cancelAfter​(long delay)
        Cancels the operation after a specified delay in milliseconds.
        Parameters:
        delay - The delay in milliseconds after which the operation will be cancelled.
      • cancelAfter

        public void cancelAfter​(long delay,
                                TimeUnit unit)
        Cancels the operation after a specified delay in the given time unit.
        Parameters:
        delay - The delay after which the operation will be cancelled.
        unit - The time unit of the delay parameter.