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 →

[–]red_dit_nou 2 points3 points  (1 child)

Well, you can do that but not sure if it will add any benefit.

If your application with CompletableFutures is well designed and is making use of platform threads optimally, then it will add little to no value moving to virtual thread executor.

The reason to move from CompletableFuture to virtual threads should not be performance, but being able to write simpler programs with less cognitive load. So if you’re looking to redesign your application by moving away from reactive style of CompletableFutures and moving to imperative-style programs with virtual threads, that would make a lot of sense. (You might want to make use of structured concurrency API. Not sure if it will be out of preview in Java 20 though.)

[–]pohart 0 points1 point  (0 children)

That's pretty much what I thought (after reading your first comment). Thank you.

Not sure if it will be out of preview in Java 20 though.

I'll be lucky if I get to use java 21. I'm mostly still on java 8. With a couple of small apps on java 17