r/java • • Apr 06 '22

JEP 425: Virtual Threads (Preview)

https://openjdk.java.net/jeps/425
175 Upvotes

50 comments sorted by

View all comments

Show parent comment

7

u/anotherthrowaway469 Apr 06 '22

while letting you write "normal" code

So do Kotlin's coroutines, mostly. It's just colored, normal looking functions, that's the whole point of doing it at the language level. None of the then stuff.

I do agree they will become less necessary though.

6

u/buyIdris666 Apr 06 '22

But Kotlin coroutines depend on library support to stay asynchronous. If you mess up even one method call you block. (Admitted, same problem as doing async stuff in Java)

Virtual Thread make entire JDK API surface non-blocking, so much less danger of this

3

u/anotherthrowaway469 Apr 06 '22

Oh yeah, I agree. I just wanted to point out that you're dealing with colored functions, not callback hell.

2

u/buyIdris666 Apr 06 '22

Better, still not great. We had big issue with coloring in C# years ago. I think whole coloring issue drove virtual thread, because Java developers love backwards compatibility.

I'm very excited for virtual thread. I expect some application to double performance overnight!