Interface Task<V>

Type Parameters:
V - the value produced by the task upon completion.
All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
NonCancellableTask, VirtualThreadTask

public interface Task<V> extends AutoCloseable
  • Method Details

    • join

    • joinUninterruptibly

      V joinUninterruptibly() throws TaskException
      Throws:
      TaskException
    • isCompleted

      boolean isCompleted()
      If this method returns true, then join() and friends are guaranteed not to block.
    • close

      void close()
      "Closes" the task. If possible, this will cancel the task. If not, the method simply returns.
      Specified by:
      close in interface AutoCloseable
    • completedTask

      static <V> Task<V> completedTask(V value)
    • wrap

      static <V> Task<V> wrap(Future<V> future)
    • nonCancellable

      static <V> Task<V> nonCancellable(Task<V> task)
    • joinOrCancel

      static <V> V joinOrCancel(Task<V> task) throws TaskException
      Throws:
      TaskException
    • uncatch

      static void uncatch(Task<?> task)
      Spawns a new virtual thread that joins the task and does not attempt to catch exceptions. If one is thrown, the default uncaught exception handler for the VM will be invoked.