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
16 lines
744 B
Plaintext
16 lines
744 B
Plaintext
$ javac src/Failures.java && java Failures (28-beta+21-ea)
|
|
-- Subtask.get() before join()
|
|
java.lang.IllegalStateException: null
|
|
-- leaving the try block without join()
|
|
java.lang.IllegalStateException: Owner did not join after forking
|
|
-- fork() from a thread that does not own the scope
|
|
returned java.lang.WrongThreadException: Current thread not owner
|
|
-- closing scopes out of order (not try-with-resources)
|
|
java.util.concurrent.StructureViolationException: null
|
|
-- join() twice
|
|
java.lang.IllegalStateException: Already joined or scope is closed
|
|
-- the failure surfaces as ExecutionException; pattern-match the cause
|
|
I/O failed: disk gone
|
|
-- two subtasks fail: which cause do you get?
|
|
cause = first (the first to fail wins)
|