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
14 lines
584 B
Plaintext
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
|