/loom-lab

Experimenting with Project Loom

Primary LanguageJavaEclipse Public License 2.0EPL-2.0

Project Loom Lab

Experiments with Project Loom's features based on these JEPs:

This includes experimenting with these features directly as well as activating them in web frameworks.

You need Java 21.

Experiments

Build the project with mvn package to get experiments/target/loom-experiments.jar. To run it:

java --enable-preview -p experiments/target/loom-experiments.jar -m loom.experiments $EXPERIMENT $ARGUMENTS

Where:

  • $EXPERIMENT selects one of the experiments by name
  • $ARGUMENTS configures the experiment

For details on these, see specific experiments below.

Disk Stats

Walks over all folders and files in a given directory to gather their respective sizes. Can be configured to either run as a single thread or with one virtual thread for each file/folder.

Echo Client & Server

A client and server that exchange messages via sockets on localhost:8080. Client protocol:

  • sends a single line, terminated by a newline
  • waits for a single line (i.e. a string terminated by a newline) to be received

Server protocol:

  • reads a single line (i.e. a string terminated by a newline) from that socket
  • waits a predetermined amount of time
  • replies with the same string, including the newline

To try this out, run the client and the server in different shells.

Note: For a much more thorough experiment with an echo server, check out Elliot Barlas' project-loom-experiment.

GitHub Crawler

Starting from a given seed URL, crawls GitHub pages and prints their connections and statistics. Only runs with virtual threads but also uses/demonstrates some data-oriented programming concepts.

Frameworks

Spring Boot

Build the project with mvn package, then run it with:

java -jar target/loom-spring-boot.jar virtual

Once launched, visit http://localhost:8080/api/current-thread.