Package edu.cnu.mdi.sim.task
Class BackgroundTasks
java.lang.Object
edu.cnu.mdi.sim.task.BackgroundTasks
Factory methods for concise one-shot background execution.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <R> TaskHandle<R> create(BackgroundTask<R> task) Creates an unstarted handle, allowing listeners to be registered before execution begins.static <R> TaskHandle<R> submit(BackgroundTask<R> task) Creates and immediately starts a task.
-
Method Details
-
create
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
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
-