T - the result typeSupplier<T>StructuredTaskScopePREVIEW<T,R> public static sealed interface StructuredTaskScope.Subtask<T> extends Supplier<T>
Subtask is a preview API of the Java platform. StructuredTaskScope.fork(Callable)PREVIEW or StructuredTaskScope.fork(Runnable)PREVIEW. Code that forks subtasks can use the get() method after joiningPREVIEW to obtain the result of a subtask that completed successfully. It can use the exception() method to obtain the exception thrown by a subtask that failed.
| Modifier and Type | Interface | Description |
|---|---|---|
static enum |
StructuredTaskScope.Subtask.StatePREVIEW |
Preview. Represents the state of a subtask. |
StructuredTaskScope.Subtask.StatePREVIEW state()
T get()
fork(Callable)PREVIEW then the result from the call method is returned. If the subtask was forked with fork(Runnable)PREVIEW then null is returned. Code executing in the scope owner thread can use this method to get the result of a successful subtask only after it has joinedPREVIEW.
Code executing in the Joiner onCompletePREVIEW method should test that the subtask state is SUCCESSPREVIEW before using this method to get the result.
Throwable exception()
fork(Callable)PREVIEW then the exception or error thrown by the call method is returned. If the subtask was forked with fork(Runnable)PREVIEW then the exception or error thrown by the run method is returned. Code executing in the scope owner thread can use this method to get the exception thrown by a failed subtask only after it has joinedPREVIEW.
Code executing in a Joiner onCompletePREVIEW method should test that the subtask state is FAILEDPREVIEW before using this method to get the exception.
IllegalStateException - if the subtask has not completed, completed with a result, or the current thread is the scope owner invoking this method before joiningPREVIEW
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/StructuredTaskScope.Subtask.html
Subtaskwhen preview features are enabled.