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
2
votes
3 answers

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 FastApi, because horizontally it scales better…
Albert Hendriks
  • 1,979
  • 3
  • 25
  • 45
2
votes
4 answers

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, then why are they separate things? Why not just make…
kqi25755
  • 21
  • 1
2
votes
1 answer

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 { public static void main…
2
votes
2 answers

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.out.println("i = " + i + ", Thread ID = " +…
Eric Kolotyluk
  • 1,958
  • 2
  • 21
  • 30
2
votes
3 answers

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 Project Loom. Under Project Loom technology with…
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
1
vote
2 answers

How to detect virtual threads on java 19

Lets say I want to ship a program that runs on java 17 as that is what is available widely, but use reflection to detect if im running on a vm with the ability to produce a thread factory via Thread.ofVirtual().name("abc").factory(). Java prohibits…
Dave Ankin
  • 1,060
  • 2
  • 9
  • 20
1
vote
0 answers

Why does joining a no-op virtual thread in a static initialiser block indefinitely?

Note: I'm well aware that creating threads in static initialisers is discouraged. Yet, exploring edge cases can provide interesting insight and uncover undesired behaviour or bugs. Hence this question. Experimenting with virtual threads in Java 20,…
michid
  • 10,536
  • 3
  • 32
  • 59
1
vote
1 answer

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 virtual threads, something like sync.Pool in Golang.
user9959339
1
vote
2 answers

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 runnable = () -> System.out.println("Inside…
SRJ
  • 2,092
  • 3
  • 17
  • 36
1
vote
1 answer

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 have something like below: //can replace this…
srock
  • 403
  • 1
  • 8
  • 17
1
vote
1 answer

How Virtual Threads are mapped to Actual thread

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, my questions are how 1 million virtual threads…
Pakira
  • 1,951
  • 3
  • 25
  • 54
1
vote
2 answers

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 JAVA_HOME env var to the jdk-18 directory, and adding…
Matt Welke
  • 1,441
  • 1
  • 15
  • 40
1
vote
2 answers

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: Executors.newVirtualThreadPerTaskExecutor() Is an API…
1
vote
1 answer

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 the performance of Java Parallel Streams or not.…
Eric Kolotyluk
  • 1,958
  • 2
  • 21
  • 30
1
vote
1 answer

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 calls in their entirety and convert them into an…
Shmuel Newmark
  • 113
  • 1
  • 6