- examples re: Project Loom
- usage of egg here is intended as an SSCCE; not a hidden feature
- SEP 2025:
main
branch uses Java 25 - eggs 1-9 work with Bash, Gradle, or Maven
- see also branches:
jdk-21
,jdk-19
(original)- branch jdk-19 has eggs 10, 11, 12 which are now obsolete
- egg_1_max_p_threads
- demo max # of platform threads
- egg_2_max_v_threads
- demo max # of virtual threads
- egg_3_legacy_exec
- illustrates legacy executor/thread pool
- egg_4_virtual_exec
- illustrates virtual threads via ExecutorService
- egg_5_sc_invoke_all
- structured concurrency
- two tasks:
foo
andbar
- can be configured to succeed or fail
- when one task is configured to fail, the other is interrupted
- egg_6_sc_invoke_any
- structured concurrency
- task
foo
and taskbar
are in a race: first one to complete is used; the other is interrupted
- egg_7_sc_deadline
- illustrates structured concurrency
- task
foo
and taskbar
take too long and exceed a deadline- both are interrupted
- egg_8_sc_custom_invoke_some
- this egg illustrates structured concurrency
- create
T
tasks- use a custom
StructuredTaskScope.Joiner
to define success whenn
tasks complete - if familiar with
invokeAny()
andinvokeAll()
, this could be consideredinvokeSome(n)
- use a custom
- NOTE: highly contrived and NOT production-ready
- egg_9_sc_fan_in
- simple
client
to send messages over a socket to aserver
- NOTE: highly contrived and NOT production-ready
- simple
- others
- egg__11*, egg__12
- see
jdk-19
branch - these may not have been moved to
jdk-21
and definitely notjdk-25
- as of September 2023, these work using Bash but not Gradle or Maven
- GitHub actions are broken, pending availability of JDK 21
- see branch
jdk-19
for this repo using JDK 19 (including Gradle and Maven) - includes examples for virtual threads
- includes examples for structured concurrency, which is "preview" in JDK 21
- we use
sc
for "structured concurrency" in the folder names
- we use
- see README for each example
- test message