Java Coroutines

Projects > Compiler and JVM Research at JKU

Coroutines are non-preemptive light-weight processes. Their advantage over threads is that they do not have to be synchronized because they pass control to each other explicitly and deterministically. Coroutines are therefore an elegant and efficient implementation construct for numerous algorithmic problems.

Publications

  • Lukas Stadler:
    Serializable Coroutines for the HotSpot™ Java Virtual Machine
    Master's thesis, Johannes Kepler University Linz, February 2011.
    This thesis provides a description of the basics of JVMs and coroutines and how they fit together, followed by an introduction into the Java API for coroutines. It shows the details of the prototype implementation, along with performance measurements and source code examples. This thesis also introduces the notion of coroutine serialization and thread-to-thread migration.
  • Lukas Stadler, Thomas Würthinger, Christian Wimmer:
    Efficient Coroutines for the Java Platform
    8th Intl. Conf. on Principles and Practice of Programming in Java (PPPJ'10), pp. 20-28. ACM Press, 2010. doi:10.1145/1852761.1852765
    This conference paper describes the basic algorithm of our prototype implementation, which combines a stack-based approach for fast switching between coroutines with a copying based approach that allows large numbers of coroutines to be generated.