Quality Outreach Heads-up - JEP 425 Virtual Threads (preview) Testing

The OpenJDK Quality Group promotes the testing of FOSS projects with OpenJDK Early-Access builds as a way to improve the overall quality of the release. This heads-up is part of a regular communication sent to the projects involved. To learn more about the program, and how-to join, please check here.

JEP 425 Virtual Threads (preview) Testing

The goal of Project Loom is to introduce in the Java platform an easy-to-use, high-throughput lightweight concurrency model, and a related new concurrent programming model.

Developed in Project Loom, JEP 425 introduces virtual threads to the Java Platform. Virtual threads are lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications. JEP 425 has now been integrated into the OpenJDK mainline, which means that Virtual Threads (preview) support is available in JDK 19 starting with JDK 19 Early-Access builds 22.

Project Loom is now getting closer and closer!

Call to Action

A lot of testing has already been done but we encourage developers to test their program(s) with the latest JDK 19 Early-Access builds, even they don’t intend to use virtual threads any time soon.

There are two approaches to test a program:

  1. Update its code to use virtual threads …or
  2. Simply test the existing unchanged code with the preview feature enabled.

Both approaches should yield valuable feedback.

Adapting an existing codebase to use virtual threads is not always limited to update the code to use virtual threads instead of platform threads as there are additional considerations. For example, virtual threads shouldn’t be pooled, code that relies heavily on thread locals will require some work to move to a world where there is a new thread for each task, etc.

And given that are some minor behavior changes and that ThreadGroup has been degraded, testing existing programs as-is, i.e., without using virtual threads but with the preview feature enabled at runtime, will also be useful. For more details, please check JEP 425 - Risks and Assumptions.

One difference between to the EA builds published by Project Loom and the latest JDK 19 EA builds is that the --enable-preview flag is required at run-time to use the new APIs. It’s not possible to use the APIs with core reflection to avoid the need for --enable-preview.

Finally, some tools especially tools relying on JVM TI agents might not be fully ready for virtual threads.

Proper feedback should be sent to the loom-dev mailing list.

Resources

~