0Pricing
Java Academy · Lesson

StructuredTaskScope

Fork and join subtasks.

Meet StructuredTaskScope

StructuredTaskScope is the core API of structured concurrency. You open a scope, fork subtasks, join to wait for them, then read their results.

It is a preview feature, so compile and run with --enable-preview.

The Basic Lifecycle

Every use follows the same four-step rhythm:

  • Open the scope in a try-with-resources block
  • fork one or more subtasks, each returning a Subtask handle
  • join to wait for completion
  • Read each subtask's result via get()

All lessons in this course

  1. The Structured Concurrency Model
  2. StructuredTaskScope
  3. Shutdown on Failure and Success
  4. Error Handling and Cancellation
← Back to Java Academy