virtual-threads Questions

2

I am a new to the latest Java versions and I found this concept of virtual threads which many servers are now using. In the same context I wanted to use a ThreadLocal field in the virtual thread co...
Upholstery asked 19/8, 2024 at 17:16

3

Solved

To my understanding one of the reasons to switch to a reactive (e.g. Project Reactor, RxJava, Vert-X) or actor (Akka) framework is because of the cost of thread switching is high. Looking at Differ...
Tureen asked 12/4, 2024 at 18:31

2

Solved

As I was reading up about virtual threads and their pitfalls I found this mention : Don't Cache Expensive Reusable Objects in Thread-Local Variables Virtual threads support thread-local variable...
Burette asked 15/3, 2024 at 11:17

1

Solved

When using StructuredTaskScope from JEP 453 in Java 21+ and forking multiple tasks, I'd like to have MDC values propagated to the forks, so that all logs are properly correlated. Extending the exam...
Metanephros asked 11/3, 2024 at 16:31

1

I am writing a library that makes extensive use of threading and would likely benefit from virtual threads in Java 21+. However, the library must also work for earlier versions of Java (possibly ba...
Carltoncarly asked 20/3, 2024 at 9:47

2

Solved

The introduction of virtual threads in Java 21 has created a lot of buzz around the community. While I still try to wrap my head around actual benefit I will be getting by this feature, I stumble u...

2

Solved

I am trying to call two external services in parallel using virtual threads on spring boot 3.2 with RestClient, but I'm not sure if it is correct to simply call them sequentially or use futures. My...
Dappled asked 17/2, 2024 at 16:33

2

Solved

I have just upgraded our Spring Boot applications to Java 21. As a part of that, I have also done changes to use virtual threads. Both when serving API requests and when doing async operations inte...
Ablation asked 26/2, 2024 at 12:51

2

Solved

Motivation: Trying to migrate Virtual Threads. Problem: Even though Virtual Threads are cheap, OS may find it suspicious for some processes to be stacked up at the same time, like searching for IP ...
Mcadams asked 4/2, 2024 at 21:46

1

Solved

In a typical servlet environment, each request gets its own thread. Adding logging MDC to generate a unique request ID to the request can be achieved with a simple servlet filter. public void doFil...
Intellect asked 4/2, 2024 at 18:36

2

I stumbled upon a problem with Virtual threads and ConcurrentHashMap. As the code below demonstrates, if you enter a lock within the computeIfAbsent, the VT may not awake, ever. It really depends h...
Dagda asked 22/1, 2024 at 16:55

2

Solved

I have an @Async task executing some database related background work. After enabling virtual threads (spring.threads.virtual.enabled: true) the number of Async jobs executed in parallel is no long...
Sindee asked 16/1, 2024 at 10:31

2

I do understand that platform threads are expensive as it needs more memory and it's prone to CPU context switching. But in case of virtual threads where an unimaginably large number of virtual thr...
Jewelfish asked 12/1, 2024 at 14:45

2

Solved

It' s recommended by JDK developers that virtual threads should never be pooled, because they are really cheap to create and destroy. I am a little confusing about the pooling idea, since pooling u...

1

In this case, i need to propagating some state like tracer/span or request context per request. The jdk env is 21.0.1-preview. I try to propagate any state between thread and virtual thread by a co...
Valse asked 26/12, 2023 at 8:10

1

Solved

If I create an executor service of virtual threads Executors.newVirtualThreadPerTaskExecutor() I understand that each tasks is run over a virtual thread. These virtual threads are scheduled (hopef...
Lenora asked 22/12, 2023 at 14:52

1

Very happy, spring-boot 3.2 is released. In Spring Boot 3.2.0 Release Notes As mentioned here, spring-boot can enable virtual threads. And tomcat and jetty can handle web requests using virtual th...
Monsignor asked 24/11, 2023 at 7:53

3

How do Java 21 virtual threads will compare to Kotlin coroutines? When coding in Kotlin, is it better to prefer one over the other? This video: Java 21 new feature: Virtual Threads #RoadTo21 seems ...

1

Solved

Is there a standard built-in Spring Boot configuration parameter to tell whether to use virtual threads or platform threads for rest controller? Or is the only way to create configuration beans, li...

1

Solved

I'm using Java Corretto 21.0.0.35.1 build 21+35-LTS, and the built-in Java HTTP client to retrieve a response as an InputStream. I'm making parallel requests using virtual threads, and for the most...
Paratroops asked 18/10, 2023 at 11:28

0

How are virtual threads parked in Project Loom, specifically in scenarios other than LockSupport.park()? I've noticed that LockSupport.park() is used in FutureTask and CompletableFuture, but what a...
Adham asked 10/10, 2023 at 0:59

2

Solved

I am working with Java 19. I have tried to use newly introduced virtual threads as follows: public static void main(String[] args) { System.out.println("Started with virutal threads"); ...
Racism asked 5/5, 2023 at 8:51

2

Solved

JEP-425: Virtual Threads states that a new virtual thread "should be created for every application task" and makes twice a reference to the possibility of having "millions" of v...
Mclin asked 8/1, 2023 at 11:56

3

Solved

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 unde...
Woollyheaded asked 17/12, 2020 at 0:46
1

© 2022 - 2025 — McMap. All rights reserved.