0Pricing
Java Academy · Lesson

Error Handling and Cancellation

Propagate failures cleanly.

Failures in a Tree of Tasks

When subtasks run concurrently, errors can happen in any branch. Structured concurrency gives you a disciplined way to propagate those failures up to the parent.

This lesson covers exceptions, cancellation, interruption, and timeouts.

Where Exceptions Surface

A subtask that throws does not crash your program immediately. The exception is captured on its Subtask handle. Where it surfaces depends on the policy:

  • ShutdownOnFailure: at throwIfFailed()
  • ShutdownOnSuccess: at result() if none succeeded

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