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).
32
questions
6
votes
0
answers
218
views
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 ...
2
votes
1
answer
50
views
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 ...
0
votes
0
answers
50
views
Virtual threads slower than single threads
I have a a number of tasks where work can be done in parallel. I have tried this single-threaded and multi-threaded. Code is as follows:
private MyTaskResult doTasks( ... ) {
try ( var scope = ...
1
vote
1
answer
96
views
How to know which platform thread is carrying the virtual thread?
Is there a way to know which platform thread is carrying the current virtual thread or pin a virtual thread to a platform thread and get its threadlocal in JDK19? I want to reuse some objects in ...
1
vote
2
answers
198
views
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 ...
2
votes
1
answer
134
views
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)?
0
votes
2
answers
135
views
Issues in running virtual threads program on intellij with java19
I am trying to run below simple program with virtual threads on my intellij with java19 version selected.
Code
public class VTSimple {
public static void main(String[] args) {
Runnable ...
2
votes
1
answer
399
views
JDK 19 preview, incubator features with Gradle [duplicate]
JDK 19 has new features: virtual threads (as preview) and structured concurrency (as incubator). Gradle 7.6 will support JDK 19. Given that 7.6-rc-1 is available, how can I try out these new features? ...
3
votes
0
answers
524
views
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)
...
2
votes
2
answers
162
views
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 ...
-1
votes
1
answer
40
views
TLAB in Virtual Thread - Project Loom
How currently TLAB is handling in Virtual Thread introduced by Project Loom in Java?
Is TLAB available in virtual threads?
11
votes
3
answers
2k
views
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
<...
2
votes
3
answers
4k
views
Java's Spring Boot vs Python's FastApi: Threads
I'm a Java Spring boot developer and I develop 3-tier crud applications. I talked to a guy who seemed knowledgeable on the subject, but I didn't get his contact details. He was advocating for Python's ...
0
votes
1
answer
120
views
Project Loom: carrier pinning
Why native code leads to carrier pinning? Is it because to switch carrier thread to another virtual thread, it should be parked from Java code?
Also, why File I/O pins a carrier thread as well right ...
14
votes
3
answers
1k
views
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 ...
2
votes
4
answers
593
views
Project loom: Why are virtual threads not the default?
According to the project loom documentation virtual threads behave like normal threads while having almost zero cost and the ability to turn blocking calls into non-blocking ones.
If this is true, ...
0
votes
2
answers
482
views
May I have Project Loom Clarified?
Brian Goetz got me excited about project Loom and, in order to fully appreciate it, I'll need some clarification on the status quo.
My understanding is as follows: Currently, in order to have real ...
0
votes
0
answers
81
views
Continuations in Loom preview not found
I just downloaded the latest early access build for Project loom, and it seems to work quite well (Thread.startVirtualThread works at least).
But when I try to import java.lang.Continuation, I get a '...
2
votes
1
answer
565
views
Problems trying to use Project Loom/Virtual Threads with OpenJDK 19-loom JAVA
I'm trying to test the virtual threads reference loom project in Java and I'm using the following JDK 19-loom version:
package com;
import java.util.concurrent.ThreadFactory;
public class a {
...
1
vote
1
answer
232
views
Java structured concurrency
Structured concurrency:
a simple principle that states that when the flow of execution splits into multiple concurrent flows, they rejoin in the same code block.
Source
Based on this, let's assume I ...
1
vote
1
answer
401
views
How Virtual Threads are mapped to Actual thread [closed]
As written, virtual threads are eventually mapped to actual threads.
Let's say there are 1 million virtual threads that are created. In a 8 core processor, I assume there will be 8 kernel threads.
So, ...
0
votes
2
answers
816
views
How do I set up a custom JDK build in sdkman?
I was able to play around with the latest early access binary for Project Loom by downloading the file from http://jdk.java.net/loom/, extracting it (I had a directory called jdk-18), setting the ...
1
vote
1
answer
247
views
Run loom demo on IDEA
I want to run loom's demo, I downloaded jdk18-loom from http://jdk.java.net/loom/, and downloaded the latest version of IDEA:
No matter I choose X or 17-preview, the program cannot run, reports:
...
11
votes
3
answers
2k
views
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 ...
1
vote
1
answer
515
views
Will Project Loom Virtual Threads improve the perfomance of parallel Streams?
This is not a duplicate of How do I write a correct micro-benchmark in Java?
The question goes to the heart of Project Loom design and implementation, and whether the project has been able to speed up ...
0
votes
3
answers
191
views
Will Exceptions in Project Loom someday purcolate up through ExecutorService contexts?
From loom-lab, given the code
var virtualThreadFactory = Thread.ofVirtual().factory();
try (var executorService = Executors.newThreadPerTaskExecutor(virtualThreadFactory)) {
IntStream.range(0, 15)...
0
votes
1
answer
229
views
Can Project Loom be used from Kotlin?
I am just getting started at playing with Project Loom...
Given the Java code which seems to work correctly
try (ExecutorService executor = Executors.newVirtualThreadExecutor()) {
IntStream.range(...
1
vote
1
answer
185
views
Is there a way to tell what Carrier Thread a Virtual Thread is running on?
I am playing around with Project Loom for the first time and I have some code
try (var executor = Executors.newVirtualThreadExecutor()) {
IntStream.range(0, 16).forEach(i -> {
System....
1
vote
1
answer
231
views
Does the Java JIT ever optimize away recursive method calls?
I know Java has yet to add tail-call elimination optimization and intends to do so as a late stage addition to Project Loom. My question is instead: does the JIT ever optimize away recursive method ...
2
votes
3
answers
712
views
Is `Thread.sleep` different with virtual threads (fibers) in Project Loom for Java
I use Thread.sleep when experimenting or demonstrating Java code for concurrency. By sleeping, I am faking some processing work taking place that will take some time.
I wonder about doing this under ...
3
votes
2
answers
170
views
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 ...
27
votes
3
answers
2k
views
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) ...