Core concept
try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
var a = scope.fork(() -> serviceA());
var b = scope.fork(() -> serviceB());
scope.join(); scope.throwIfFailed();
}Advertisement
How it works
Preview through Java 24+.
Advertisement
Trade-offs + gotchas
Correlated parallel service calls.