Interface Timer

All Superinterfaces:
AsyncResult<Void>, Comparable<Delayed>, Delayed, Future<Void>

public interface Timer extends Future<Void>, Delayed
A timer task that can be used as a future. The future is completed when the timeout expires, when the task is cancelled the future is failed with a CancellationException.
Author:
Julien Viet
  • Method Details

    • cancel

      boolean cancel()
      Attempt to cancel the timer task, when the timer is cancelled, the timer is failed with a CancellationException.
      Returns:
      true when the future was cancelled and the timeout didn't fire.
    • getDelay

      long getDelay(TimeUnit unit)
      Specified by:
      getDelay in interface Delayed
    • compareTo

      int compareTo(Delayed o)
      Specified by:
      compareTo in interface Comparable<Delayed>