import java.util.concurrent.ExecutionException;
import java.util.concurrent.StructuredTaskScope;

public class Test {

    public static void main(String[] args) {
        try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {

            scope.shutdown();

            StructuredTaskScope.Subtask<String> subtask = scope.fork(() -> "result");

            scope.join().throwIfFailed();

            subtask.get(); // IllegalStateException: Owner did not join after forking subtasks

        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }
    }

} 