Demo: a thread pool that silently drops work
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
- Start a pool with 2 threads, a queue of 2, and
DiscardPolicy. - Submit 10 slow tasks; count completions: only 4 finish, with no error.
- Switch to
AbortPolicy; catchRejectedExecutionExceptionand see the rejected count. - Planned mistake: use
submitwith a task that throws and never callget(); the failure vanishes. Fix: wrap the task body in try/catch with logging, or inspect the futures. - 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.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.