Questions tagged [project-loom]

Project Loom pertains to features and APIs in the Java VM regarding lightweight concurrency and related programming models. Examples include virtual threads (preview in JDK 19) and structured concurrency (incubating in JDK 19).

Project Loom pertains to features and APIs in the Java VM regarding lightweight concurrency and related programming models. Examples include virtual threads (JEP-425 feature introduced in Java 19 as a preview feature) and structured concurrency (incubating in JDK 19).

40 questions
27
votes
3 answers

Project loom: what makes the performance better when using virtual threads?

To give some context here, I have been following Project Loom for some time now. I have read The state of Loom. I have done asynchronous programming. Asynchronous programming (provided by Java NIO) returns the thread to the thread pool when the task…
Ashwin
  • 12,691
  • 31
  • 118
  • 190
19
votes
3 answers

What exactly makes Java Virtual Threads better

I am pretty hyped for Project Loom, but there is one thing that I can't fully understand. Most Java servers use thread pools with a certain limit of threads (200, 300 ..), however, you are not limited by the OS to spawn many more, I've read that…
Borislav Stoilov
  • 3,247
  • 2
  • 21
  • 46
15
votes
3 answers

Project loom, what happens when virtual thread makes a blocking system call?

I was investigating how Project Loom works and what kind of benefits it can bring to my company. So I understand the motivation, for standard servlet based backend, there is always a thread pool that executes a business logic, once thread is blocked…
Almas Abdrazak
  • 3,209
  • 5
  • 36
  • 80
14
votes
1 answer

Using Virtual Threads (Project Loom) with Spring WebFlux/Reactor/Reactive libraries

Java Virtual Threads In Java 19 were introduced Virtual Threads JEP-425 as a preview feature. After some investigation of concept of Java Virtual Threads (Project Loom), called sometimes lightweight threads (or sometimes fibers or green threads),…
kerbermeister
  • 2,985
  • 3
  • 11
  • 30
11
votes
3 answers

How can I run JDK 19 with Structured Concurrency?

I have edited this to bring things up-to-date wrt the original posting. I want to try the new Project Loom feature defined in: JEP 428: Structured Concurrency (Incubator) I have in my pom.xml
Eric Kolotyluk
  • 1,958
  • 2
  • 21
  • 30
5
votes
0 answers

How do I safely call CPU-bound code from within a Java19 virtual thread?

We have a Jetty webapp with a custom threadpool backed by Java19 virtual threads. The business logic we run in response to a request is usually IO-bound (e.g. DB queries), so virtual threads have been a great win for us, allowing us to have many…
tsutsu
  • 63
  • 3
5
votes
1 answer

In Loom, can I use virtual threads for Recursive[Action/Task]?

Is it possible to use RecursiveAction, for example, in conjunction with -- instead of the fork/join pool -- a pool of virtual threads (before I attempt a poorly-designed, custom effort)?
HellishHeat
  • 2,280
  • 4
  • 31
  • 37
4
votes
0 answers

Virtual Threads in Tomcat Server

I'm using OpenJDK 19 openjdk 19 2022-09-20 OpenJDK Runtime Environment (build 19+36-2238) OpenJDK 64-Bit Server VM (build 19+36-2238, mixed mode, sharing) And the latest version of Tomcat (10.0.23) var tomcat = new Tomcat(); var ctx =…
areller
  • 4,800
  • 9
  • 29
  • 57
3
votes
1 answer

Synchronize block pinning virtual thread

I am an enthusiast and am wondering about virtual threads. In the docs it says that one of the conditions to pin the thread is in a synchronized block, and in those cases to use a semaphore. Here are the docs to the JEP…
3
votes
2 answers

Detect Project Loom technology as missing or present JVM at runtime

Project Loom is now available in special early-release builds of Java 16. If I were to run my Loom-based app on a Java implementation lacking in the Project Loom technology, is there a way to detect that gracefully early in my app launching? I want…
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
2
votes
1 answer

How is the deprecated Green Threads different from Project Loom?

In the very early Java versions, JVM threads multiplexed to native OS threads. Such threads were called Green Threads. This was deprecated in the very early versions of Java and then every Java thread corresponded to an OS thread. However, with…
JavaNovice
  • 1,083
  • 1
  • 12
  • 20
2
votes
1 answer

Does a virtual thread wake up in the same carrier thread on which it was blocked?

Is my understanding correct that a virtual thread runs on the same carrier thread throughout its lifetime? If not, then I'm wondering if we'd need to have our instance variables as volatile to have the correct value after a virtual threads blocks in…
Sanjay
  • 8,755
  • 7
  • 46
  • 62
2
votes
2 answers

How does a Java virtual thread know when the thread is waiting?

When a virtual thread is blocked due to synchronized call, it's yielding, so the scheduler will unmount it from related Carrier thread. I was wondering, how does a virtual thread know that it's currently at wait state and it's time to yield?
Amit Erez
  • 21
  • 2
2
votes
1 answer

Java 19 preview, incubator features with Gradle

Java 19 has new features: virtual threads (as preview) and structured concurrency (as incubator). Gradle 7.6 will support Java 19. Given that 7.6-rc-1 is available, how can I try out these new features? I have working Bash scripts like the…
Michael Easter
  • 23,733
  • 7
  • 76
  • 107
2
votes
2 answers

Minimum concurrency to benefit from JDK19 virtual threads

According to JEP 425, virtual threads can significantly improve application throughput when the number of concurrent tasks is high (more than a few thousand), and the workload is not CPU-bound Why are virtual threads not helpful when the thread…
Andrew Parks
  • 6,358
  • 2
  • 12
  • 27
1
2 3