Interface Task

All Superinterfaces:
Comparable<Task>, Runnable
All Known Implementing Classes:
AbstractTask, LambdaTask, ReflectTask, RunnableTask, TaskScheduler.TimerTask

public interface Task extends Runnable, Comparable<Task>
Represents a Runnable with a priority.
Since:
2.6
API Note:
Before version 2.9, this was an abstract class. The class was partially moved to AbstractTask.
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    Compares this Task to the given Task.
    int
    Returns the priority of this task.
    void
    run()
    Runs this Task.
  • Method Details

    • run

      void run()
      Runs this Task. Exact behavior is implementation-defined.

      General behavior includes running a task handler (for example a method).

      Specified by:
      run in interface Runnable
      Throws:
      ExecutionFailedException - If an error occurs during execution of the task
    • getPriority

      int getPriority()
      Returns the priority of this task. A lower priority number means this task has a higher priority.
      Returns:
      The priority of this task
    • compareTo

      default int compareTo(Task o)
      Compares this Task to the given Task.

      The return value is negative if this priority task has higher priority than the given priority task (meaning a lower priority number), positive if this task has lower priority than the given task, and 0 if the priority of both tasks is equal.

      Specified by:
      compareTo in interface Comparable<Task>
      Returns:
      A negative integer, zero, or a positive integer if this task has higher, equal, or lower priority than the given task, respectively