Files
java-core-examples/executors/output/02-graceful-shutdown-pattern.txt
asmhatreandClaude Sonnet 5 bc5153d2a5 executors: ExecutorService lifecycle companion code
Adds the executors module: shutdown() vs shutdownNow(), the graceful
two-phase shutdown pattern, AutoCloseable/try-with-resources (JDK 19+),
newVirtualThreadPerTaskExecutor() timing vs a bounded pool, and the
submit()-without-get() lost-exception trap. 5 runnable demos, 1 JUnit
correctness test class (23 tests), 6 captured output transcripts.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FhzLY5p6okFva3qsnsRyvM
2026-09-30 06:54:17 +00:00

14 lines
584 B
Plaintext

=== Case 1: tasks finish comfortably inside the grace period ===
quickPool: shutdown() called, waiting up to 1s for a clean finish
quick-task-1: done (200ms)
quick-task-0: done (200ms)
quickPool: terminated cleanly within the grace period
=== Case 2: a task outlives the grace period, forcing shutdownNow() ===
slowPool: shutdown() called, waiting up to 1s for a clean finish
slow-task: started, will try to sleep 3s
slowPool: grace period expired, escalating to shutdownNow()
slow-task: interrupted during shutdownNow(), stopping early
slowPool: terminated after shutdownNow()
done