- Type Parameters:
T
- the result type
- All Superinterfaces:
Supplier<T>
- Enclosing class:
StructuredTaskScopePREVIEW<T>
Subtask
is a preview API of the Java platform.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Represents a subtask forked with
StructuredTaskScope.fork(Callable)
PREVIEW.- Since:
- 21
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Preview.Represents the state of a subtask. -
Method Summary
-
Method Details
-
task
Returns the value returning task provided to thefork
method.- API Note:
- Task objects with unique identity may be used for correlation by
implementations of
handleComplete
PREVIEW. - Returns:
- the value returning task provided to the
fork
method
-
state
Returns the state of the subtask.- Returns:
- the state of the subtask
-
get
T get()Returns the result of the subtask.To ensure correct usage, if the scope owner forksPREVIEW a subtask, then it must join (with
join
PREVIEW orjoinUntil
PREVIEW) before it can obtain the result of the subtask.- Specified by:
get
in interfaceSupplier<T>
- Returns:
- the possibly-null result
- Throws:
IllegalStateException
- if the subtask has not completed, did not complete successfully, or the current thread is the task scope owner and did not join after forking- See Also:
-
exception
Throwable exception()Returns the exception thrown by the subtask.To ensure correct usage, if the scope owner forksPREVIEW a subtask, then it must join (with
join
PREVIEW orjoinUntil
PREVIEW) before it can obtain the exception thrown by the subtask.- Returns:
- the exception thrown by the subtask
- Throws:
IllegalStateException
- if the subtask has not completed, completed with a result, or the current thread is the task scope owner and did not join after forking- See Also:
-
Subtask
when preview features are enabled.