Interface Timer

All Known Implementing Classes:
HashedWheelTimer

public interface Timer
Schedules TimerTasks for one-time future execution in a background thread.
  • Method Summary

    Modifier and Type
    Method
    Description
    newTimeout(TimerTask task, long delay, java.util.concurrent.TimeUnit unit)
    Schedules the specified TimerTask for one-time execution after the specified delay.
    java.util.Set<Timeout>
    Releases all resources acquired by this Timer and cancels all tasks which were scheduled but not executed yet.
  • Method Details

    • newTimeout

      Timeout newTimeout(TimerTask task, long delay, java.util.concurrent.TimeUnit unit)
      Schedules the specified TimerTask for one-time execution after the specified delay.
      Returns:
      a handle which is associated with the specified task
      Throws:
      java.lang.IllegalStateException - if this timer has been stopped already
      java.util.concurrent.RejectedExecutionException - if the pending timeouts are too many and creating new timeout can cause instability in the system.
    • stop

      java.util.Set<Timeout> stop()
      Releases all resources acquired by this Timer and cancels all tasks which were scheduled but not executed yet.
      Returns:
      the handles associated with the tasks which were canceled by this method