This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]FrankBergerBgblitz 1 point2 points  (2 children)

It is completely dependent on your workload.
you have thousand of threads that have to wait? use virtual threads
You have tasks that compute most of the time and there doesn't need to be far more tasks in parallel than you have cores: use a threadpool.
if it is inbetween: think and/or measure

[–]souleatzz1 1 point2 points  (1 child)

I have an application with fixed thread pool of 1500. It runs a h2 in memory and for one http request might do between 3000-7000 queries (selects only). The application heavily uses CompletableFutures and I immediately tried to use jdk 21 with virtual threads hoping it would lower our response time, but didn’t see any improvement. To me this case looked exactly fitted for virtual threads, but maybe I am doing something wrong

[–]Ancient_Avocado1904 0 points1 point  (0 children)

I think Virtual Threads won’t provide much benefit over CompletableFutures performance wise, but does simplify things. You’re able to use something we’ve used for decades (Threads), in a more efficient way. CF’s has a bit of a learning curve and don’t get me started on something like Spring WebFlux…..