Closed apatrida closed 1 year ago
Hi @apatrida, thank you so much for your contribution. I didn't knew that it was possible to dispatch coroutines onto Loom Virtual Threads. It is indeed a good addition to this repository. Thank you for letting me know!
Nice article!
Have you considered dispatching Kotlin coroutines onto Loom VirtualThreads?
Example idea: https://kt.academy/article/dispatcher-loom
Here just create a simple dispatcher...
And change your
async { ... }
call to use this dispatcher asNote your
controlTest
can have both aThread { ... }
version and aThread.startVirtualThread { ... }
version since nothing stops Kotlin from using LOOM virtual threads directly.A lot of this code in the samples can be shared between them as Kotlin has no problem accessing Java classes, and most concepts in Kotlin are readable from Java as well. Unless you are worried about performance of basic code between the two, the total codebase could be reduced.
sample run-local with Java, Kotlin coroutines, Kotlin w/Loom async coroutines
That last
controlTest-Loom
is just KotlincontrolTest
changed to useVirtualThread