If you use Java, at the end of 2017, 2 options are available:
Both are based on commons-javaflow - they rewrite your code at the bytecode level to make it work.
I support Coroutines - Surfaces is that it is fast, it supports all major build systems and supports serialization / versioning of your coroutines. The downside is that the API has a few deviations from commons-javaflow.
Vsilaev supports Tasclate-Javaflow - I didnโt use it, so I canโt talk about it, but it is also supported by viewing examples that the API aligns with commons-javaflow examples.
Kotlin also has language features and Scala (and possibly other JVM-based languages) that allow coroutines to be used. But before switching languages, you should know that Kotlin, Scala, or something like the du jour JVM language is not Java today and never will be. No matter what he does in the background, to make things work, it may not work when the next version of the JVM rolls.
People who support the JDK at Oracle have experience using these third-party JVM languages โโas market research. If a high-level function is added to a third-party JVM language and is quite popular, they will include it in Java. This is what is happening right now with coroutines. There is an OpenJDK project called Project Loom , which aims to add coroutines to the Java language.
These are the first days for Project Loom. If you critically review this offer, this is a mess. I am sure that it will stabilize over time, but what we ultimately get may be completely different from what many of us expect.
To repeat, your options should either use one of the bytecode toolkit tools or switch languages. Project Loom is still in the early days, and it is likely that it can never be added to Java.
offbynull Dec 27 '17 at 16:08 2017-12-27 16:08
source share