Lab 8 · Structured Concurrency

Difficulty: Advanced Time: 60 minutes Topics: StructuredTaskScope, Joiner, ScopedValue

Requires: Java 21+ (preview)


Objectives

  • ✅ Use StructuredTaskScope for parent-child relationships
  • ✅ Structure tasks with clear completion guarantees
  • ✅ Handle failures with Joiner strategies
  • ✅ Use ScopedValue for clean context passing

Key Exercises

Exercise 1: Basic StructuredTaskScope with awaitAll() Exercise 2: failFast joiner for cancellation Exercise 3: Error handling with JoinedException Exercise 4: ScopedValue for context passing


References