import java.util.concurrent.StructuredTaskScope; /** The JDK 21-24 API that older tutorials still show. It is not in 25 or later. */ public class ShutdownOnFailure { public static void main(String[] args) throws Exception { try (var scope = new StructuredTaskScope.ShutdownOnFailure()) { var user = scope.fork(() -> "Alice"); scope.join().throwIfFailed(); System.out.println(user.get()); } } }