Add structured-concurrency-final module: StructuredTaskScope final in JDK 28 (JEP 543), run on 28-ea, 27, 26 and 25

Runnable demos for the ankurm.com structured-concurrency-java article: the ExecutorService thread leak and its fix, every built-in Joiner,
structure violations, timeouts, a custom Joiner, JSON thread dumps (in-process and jcmd), scoped values, javap diffs of the API on 25, 26, 27 and 28-ea,
compiler output for six pieces of 25/26-era code, and the preview class-file trap between 27 and 28. Transcripts in output/.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CifR2BE7PBvRy5hT8TS9oz
This commit is contained in:
Claude
2026-10-26 02:01:31 +00:00
parent 2e25042a68
commit c93a1fffbb
37 changed files with 1351 additions and 0 deletions
@@ -0,0 +1,15 @@
$ javac src/Timeouts.java && java Timeouts (28-beta+21-ea)
-- inside the deadline
[fast, fast]
-- deadline 200 ms, one subtask needs 5 s
ExecutionException, cause = java.util.concurrent.StructuredTaskScope$CancelledByTimeoutException
returned within well under a second (not 5 s): the slow subtask was interrupted
-- the same deadline with a joiner whose timeout() returns a partial result
join() = [fast]
-- a thread factory decides the subtask thread's name
[order-0, order-1]
$ javac src/CollectingJoiner.java && java CollectingJoiner (28-beta+21-ea)
collected (sorted): [1, 3]
-- with a 100 ms timeout and a 5 s subtask
CompletionException, cause = java.util.concurrent.StructuredTaskScope$CancelledByTimeoutException