6 ms·
If you run this on JDK19 with *--enable-preview*, Javalin will use Virtual Threads for the Server ThreadPool (as well as all other ThreadPools it has).
by tipsee 4y ago
If you run this on JDK19 with *--enable-preview*, Javalin will use Virtual Threads for the Server ThreadPool (as well as all other ThreadPools it has).
- daveidol 4y agoHow does it compare to coroutines in Kotlin?
- stefs 4y agoi'd be interested in this too. my guess: virtual threads are slightly more memory efficient and slightly faster, but same ballpark.
- stefs 4y agonow that i think about it i'm pretty sure my guess is completely wrong. memory usage (and thus concurrent-inactives) might be similar, but i expect the virtual threads to be much more efficient.
- stefs 4y agoexcept if you use the appropriate non-blocking methods! with blocking io, kotlin coroutines are just running in a thread pool.
- tipsee 4y agoI mean, it sort of doesn't? Coroutines is a whole concept, Virtual Threads can in most cases just replace java.lang.Threads, which is how it's implemented in Javalin. We just swap out the OS Threads for Virtual Threads.