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
34 lines
1.2 KiB
Bash
Executable File
34 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Regenerates every file in ../output/. Requires JDK25_HOME (and JAVA_HOME pointed at it for the
|
|
# Maven build). All demos in this module run on a single modern JDK - there's no cross-version
|
|
# comparison needed here, unlike vt-pinning or synchronizers.
|
|
set -euo pipefail
|
|
|
|
if [[ -z "${JDK25_HOME:-}" ]]; then
|
|
echo "JDK25_HOME must be set (e.g. /path/to/jdk-25)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cd "$(dirname "$0")/.."
|
|
OUT=output
|
|
mkdir -p "$OUT"
|
|
|
|
JAVA_HOME="$JDK25_HOME" mvn -q -f ../pom.xml -pl executors -am package
|
|
|
|
run() {
|
|
local class=$1
|
|
local outfile=$2
|
|
echo "==> $class"
|
|
"$JDK25_HOME/bin/java" -cp target/classes "com.ankurm.executors.$class" 2>&1 | grep -v "Picked up" > "$OUT/$outfile"
|
|
}
|
|
|
|
run ShutdownVsShutdownNowDemo 01-shutdown-vs-shutdownnow.txt
|
|
run GracefulShutdownPatternDemo 02-graceful-shutdown-pattern.txt
|
|
run AutoCloseableExecutorDemo 03-autocloseable-executor.txt
|
|
run VirtualThreadPerTaskExecutorDemo 04-virtual-thread-per-task-executor.txt
|
|
run LostExceptionTrapDemo 05-lost-exception-trap.txt
|
|
|
|
cp target/surefire-reports/com.ankurm.executors.ExecutorShutdownBehaviorTest.txt "$OUT/06-correctness-tests.txt"
|
|
|
|
echo "Done. See $OUT/"
|