Adds the concurrency-interview module: a real race condition with its actual lost-update count, why volatile alone doesn't fix it, a real JVM-detected deadlock (ThreadMXBean.findDeadlockedThreads()) with the fix, and ScopedValue's exact child-thread inheritance rules (finalized in JDK 25 via JEP 506, demonstrated against StructuredTaskScope, still preview per JEP 505/525). 4 runnable demos, 1 JUnit test class (9 tests), 5 captured output transcripts. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FhzLY5p6okFva3qsnsRyvM
33 lines
1.1 KiB
Bash
Executable File
33 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Regenerates every file in ../output/. Requires JDK25_HOME. Every demo in this module needs
|
|
# --enable-preview to run (ScopedValueDemo uses StructuredTaskScope, still preview in JDK 25/26),
|
|
# even though ScopedValue itself is finalized (JEP 506).
|
|
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 concurrency-interview package
|
|
|
|
run() {
|
|
local class=$1
|
|
local outfile=$2
|
|
echo "==> $class"
|
|
"$JDK25_HOME/bin/java" --enable-preview -cp target/classes "com.ankurm.concurrencyinterview.$class" 2>&1 | grep -v "Picked up" > "$OUT/$outfile"
|
|
}
|
|
|
|
run RaceConditionDemo 01-race-condition.txt
|
|
run VolatileNotEnoughDemo 02-volatile-not-enough.txt
|
|
run DeadlockDemo 03-deadlock-detection.txt
|
|
run ScopedValueDemo 04-scoped-value-inheritance.txt
|
|
|
|
cp target/surefire-reports/com.ankurm.concurrencyinterview.InterviewClaimsTest.txt "$OUT/05-correctness-tests.txt"
|
|
|
|
echo "Done. See $OUT/"
|