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
22 lines
950 B
Plaintext
22 lines
950 B
Plaintext
$ javac src/Joiners.java && java Joiners (28-beta+21-ea)
|
|
-- allSuccessfulOrThrow(): List in FORK order, not completion order
|
|
[slow, fast, medium]
|
|
-- allSuccessfulOrThrow(): one failure cancels the others, join() throws ExecutionException
|
|
ExecutionException, cause = java.lang.IllegalStateException: broken failed
|
|
interrupted: [slow]
|
|
-- anySuccessfulOrThrow(): the race; losers are interrupted
|
|
winner: B-50ms
|
|
interrupted: [A-300ms, C-300ms]
|
|
-- anySuccessfulOrThrow(): when every subtask fails
|
|
ExecutionException, cause = java.lang.IllegalStateException: one failed
|
|
-- awaitAllSuccessfulOrThrow(): returns null (Void), like the zero-argument open()
|
|
join() = null, a=a, b=b
|
|
-- allUntil(predicate): stop when two subtasks have completed
|
|
SUCCESS t1
|
|
SUCCESS t2
|
|
UNAVAILABLE
|
|
UNAVAILABLE
|
|
interrupted: [t3, t4]
|
|
-- the Function overload: join() throws OUR exception type
|
|
caught ServiceException: service call failed: orders failed
|