Skip to content
Ameen Abozaid
Planned lessonMID-006-L04

Timeouts and cancellation

  • Lesson 4 of 6
  • Mid-level
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

bound waiting time.

Planned topics

  • orTimeout(d, unit) fails with TimeoutException; completeOnTimeout(value, d, unit) supplies a default (Java 9+).
  • cancel(true) on a CompletableFuture does not interrupt the running task; design tasks to check for cancellation.
  • Apply a deadline to the whole fan-out and per-call timeouts to each.
  • A timeout does not stop the remote work; pair with client-side timeouts.
  • Combine: timeout then fallback.
Draft outline details

Demonstration

java
reviews.completeOnTimeout(List.of(), 300, TimeUnit.MILLISECONDS);

Check your understanding

Does cancel(true) interrupt the thread in a CompletableFuture?

Show answer

No.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.