Class BackgroundTasks

java.lang.Object
edu.cnu.mdi.sim.task.BackgroundTasks

public final class BackgroundTasks extends Object
Factory methods for concise one-shot background execution.
  • Method Details

    • create

      public static <R> TaskHandle<R> create(BackgroundTask<R> task)
      Creates an unstarted handle, allowing listeners to be registered before execution begins.
      Type Parameters:
      R - result type
      Parameters:
      task - task to wrap
      Returns:
      new unstarted handle
    • submit

      public static <R> TaskHandle<R> submit(BackgroundTask<R> task)
      Creates and immediately starts a task.

      Use create(BackgroundTask) when no callback may be missed, because a very short submitted task can finish before a listener is added.

      Type Parameters:
      R - result type
      Parameters:
      task - task to run
      Returns:
      started handle