Skip to content
Ameen Abozaid
Planned lessonMID-003-L07

Demo: a thread pool that silently drops work

  • Lesson 7 of 7
  • Mid-level
On This Lesson 3 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

find lost tasks caused by a rejection policy and swallowed errors.

Draft outline details

Step by step

  1. Start a pool with 2 threads, a queue of 2, and DiscardPolicy.
  2. Submit 10 slow tasks; count completions: only 4 finish, with no error.
  3. Switch to AbortPolicy; catch RejectedExecutionException and see the rejected count.
  4. Planned mistake: use submit with a task that throws and never call get(); the failure vanishes. Fix: wrap the task body in try/catch with logging, or inspect the futures.
  5. Decide a policy: caller-runs for backpressure or abort plus metric; never silent discard for business work.

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.

Type to search levels, phases, modules and lessons.