• Stars
    star
    115
  • Rank 304,121 (Top 7 %)
  • Language
    Java
  • License
    Eclipse Public Li...
  • Created over 2 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Experimenting with Project Loom

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

Change into the project folder experiments and build it with mvn package to get target/loom-experiments.jar. To run it:

java --enable-preview -p 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

Change into the project folder frameworks/spring_boot and build with mvn package, then run it with:

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

Once launched, visit http://localhost:8080/api/current-thread. To switch to virtual threads, append the command line parameter virtual. The switch is implemented in SpringBootApplication, which explicitly replaces the executors used to submit requests to.

As far as I know, the blog post Embracing Virtual Threads is the most up-to-date documentation on Spring and virtual threads.

Quarkus

Change into the project folder frameworks/quarkus and build with mvn package, then run it with:

java --add-opens java.base/java.lang=ALL-UNNAMED -jar target/quarkus-app/quarkus-run.jar

Once launched, visit http://localhost:8080/api/current-thread. To switch to virtual threads, edit QuarkusEndpoints and uncomment @RunOnVirtualThread, which allows configuring virtual threads for individual endpoints. This annotation requires the --add-opens. The artifact quarkus-netty-loom-adaptor (see pom.xml) seems to improve performance of Quarkus on virtual threads.

As far as I know, the blog post Writing simpler reactive REST services with Quarkus Virtual Thread support is the most up-to-date documentation on Quarkus and virtual threads.

More Repositories

1

demo-java-x

Demonstrates Java 9-18's new features
Java
301
star
2

demo-jpms-monitor

A small application to demonstrate the Java Platform Module System
Java
72
star
3

demo-junit-5

Demonstrating JUnit 5 features
Java
71
star
4

modern-java-demo

Modern Java in Action
Java
60
star
5

LibFX

Makes Java even more fun!
Java
53
star
6

slides

Slides for various talks I give
CSS
34
star
7

java-after-eight

Start with Java 11, be amazed by Java 12-17 and beyond
Java
27
star
8

effective-java

Exploration of Effective Java, third edition
Java
26
star
9

module-system-woes

Solutions to common troubles with Java's module system
Java
24
star
10

demo-java-9-migration

A demo code base for a Java 9 migration
Java
23
star
11

record-args

A simple command-line argument parser for Java applications that relies on records.
Java
16
star
12

JDeps-Maven-Plugin

Includes JDeps in Maven
Java
16
star
13

demo-jigsaw-advent-calendar

An Advent Calendar Demonstrating Jigsaw EA
16
star
14

demo-decorator-java-8

Demonstrates how the decorator pattern could be implemented using the features of Java 8.
Java
15
star
15

advent-of-code-2023

Java solutions for Advent of Code 2023
Java
14
star
16

mvn-java-9

Java
13
star
17

nipafx.dev

My website
JavaScript
12
star
18

java-ecosystem-map

A visualization of the core concepts of the Java ecosystem.
TypeScript
9
star
19

demo-jpms-hello-world

Simple Hello-World example for the Java Platform Module System (JPMS)
Java
8
star
20

livefx

Java
6
star
21

lab-junitlambda

Toying around with the JUnit Lambda Prototype
Java
5
star
22

demo-jigsaw-reflection

Demonstrates how strongly Jigsaw encapsulates module internals against reflection
Shell
5
star
23

demo-javadoc-8-tags

Demonstrates the new Javadoc tags used in Java 8
CSS
4
star
24

demo-serialization-proxy-pattern

Demonstrates the Serialization Proxy Pattern
Java
4
star
25

calendar

A simple calendar view
TypeScript
3
star
26

benchmarks

Arbitrary Java performance benchmarks
Java
3
star
27

demo-serialize-optional

Demonstrates how Optionals can be (de)serialized.
Java
3
star
28

demo-java9-jsr305

How to use JSR-305 on Java 9
Shell
2
star
29

Caliz

Wrapping Graal AOT for fast scripts with Java
Java
2
star
30

demo-elvis-operator

Shows how to create an Elvis (or null coalescing) operator with lambda expressions.
Java
1
star
31

ginevra

A Gatsby-like static site generator
Java
1
star