Interface Task

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Task
Piece of code that that has no result and may throw an exception. Similar to Runnable or Callable.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Task
    of(Runnable runnable)
    Creates a Task from Runnable.
    static Task
    of(Callable callable)
    Creates a Task from Callable.
    void
    run()
    Runs a code or throws an exception if unable to do so.
    default Callable
    Wraps a task into a callable that returns null.
    default Runnable
    Wraps a task into a runnable.
  • Method Details

    • of

      static Task of(Runnable runnable)
      Creates a Task from Runnable.
    • of

      static Task of(Callable callable)
      Creates a Task from Callable.
    • toRunnable

      default Runnable toRunnable()
      Wraps a task into a runnable.
    • toCallable

      default Callable toCallable()
      Wraps a task into a callable that returns null.
    • run

      void run() throws Exception
      Runs a code or throws an exception if unable to do so.
      Throws:
      Exception - if unable to execute task