Platform Threads: Ø Thin wrapper over OS threads Ø One-to-one mapping with OS threads Ø Thread pools Virtual Threads Virtual Threads: Ø Lightweight user threads Ø Highly scalable Ø No need for pooling
splits into multiple concurrent flows, they rejoin in the same code block Benefits: Ø Error handling with short-circuiting Ø Cancellation propagation Ø Clarity Ø Observability
Get customer details Ø Using customer details Ø Get accounts Ø Get loans Ø Get external credit scores Ø Two services provide this score Ø Response from one is enough Ø Aggregate all this info and send to offer-calculation service
the same copy Ø Inherited through the StructuredTaskScope to the child-virtual-threads Ø Bounded by the scope ScopedValue VALUE = ScopedValue.newInstance(); ScopedValue.where(VALUE, someValue) .run(() -> {...});