Interface StructuredTaskScope.Subtask<T>
- 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 SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic enumPreview.Represents the state of a subtask.
- 
Method Summary
- 
Method Details- 
taskReturns the value returning task provided to theforkmethod.- API Note:
- Task objects with unique identity may be used for correlation by
 implementations of handleCompletePREVIEW.
- Returns:
- the value returning task provided to the forkmethod
 
- 
stateReturns the state of the subtask.- Returns:
- the state of the subtask
 
- 
getT get()Returns the result of the subtask.To ensure correct usage, if the scope owner forksPREVIEW a subtask, then it must join (with joinPREVIEW orjoinUntilPREVIEW) before it can obtain the result of the subtask.- Specified by:
- getin interface- Supplier<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:
 
- 
exceptionThrowable exception()Returns the exception thrown by the subtask.To ensure correct usage, if the scope owner forksPREVIEW a subtask, then it must join (with joinPREVIEW orjoinUntilPREVIEW) 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:
 
 
- 
Subtaskwhen preview features are enabled.