This discussion is archived
2 Replies Latest reply: Mar 13, 2013 2:18 AM by gimbal2 RSS

Coroutines in Java?

668085 Newbie
Currently Being Moderated
I'd like to be able to use coroutines in Java (http://en.wikipedia.org/wiki/Coroutine), but as far as I can tell Java does not currently support this.

I've come across a few projects that will provide coroutine-like abilities by modifying your byte code, but I'm afraid that this would not be very portable.

Is there any way to implement coroutines in Java? Is this a feature which may be added to a future Java release?
  • 1. Re: Coroutines in Java?
    Kayaman Guru
    Currently Being Moderated
    kitfox wrote:
    I'd like to be able to use coroutines in Java (http://en.wikipedia.org/wiki/Coroutine), but as far as I can tell Java does not currently support this.
    You're correct.
    I've come across a few projects that will provide coroutine-like abilities by modifying your byte code, but I'm afraid that this would not be very portable.
    Apparently there are some that break bytecode portability and others that don't.
    Is there any way to implement coroutines in Java?
    You just mentioned ways.
    Is this a feature which may be added to a future Java release?
    Possibly, but I wouldn't hold my breath. If you want to use coroutines now, I'd suggest you choose a language that supports them.
  • 2. Re: Coroutines in Java?
    gimbal2 Guru
    Currently Being Moderated
    Kayaman wrote:
    Possibly, but I wouldn't hold my breath. If you want to use coroutines now, I'd suggest you choose a language that supports them.
    According to that wikipedia page, C# supports it. That is at least a language that is very similar to Java. Of course the platform is totally different and Microsofty.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points