5

I know that my question is more academic than a real issue. In most cases a thread implementation with Fiber-like logic would be OK. But is there any way to implement Fibers as they are described in the JVM?

Is there any framework that is missing me to achieve that?

Dante May Code
  • 11,177
  • 9
  • 49
  • 81
Evan P
  • 1,767
  • 1
  • 20
  • 37
  • 2
    A Google search ("java" & "fiber") will give you answers - e.g. http://code.google.com/p/jetlang/. Please attempt to do your own research before you ask an SO question. – Stephen C Dec 17 '12 at 00:19
  • Sometimes fibers are also known as user-mode scheduling, maybe that can help you. – Chris O Dec 17 '12 at 00:20
  • @Stephen C I have seen Jetlang, even it names its therads as "Fibers" they are not. They are small rescheduled threads. No co-operation is involved. – Evan P Dec 17 '12 at 00:23
  • @Chris O how can this be implemented. Since all threads are executed by the same user in the JVM – Evan P Dec 17 '12 at 00:24
  • OK ... so what about all of the other hits? Don't any of them answer your question? – Stephen C Dec 17 '12 at 00:29
  • @Stephen C Most of them, are using a thread-like logic (that i mentioned) that's why i asked. To make sure if there is anything else that I might be missing. – Evan P Dec 17 '12 at 00:32
  • 2
    @BagosGiAr: To make your question more constructive, please edit it to cite what approaches you have examined and how each comports with your expectations. – trashgod Dec 17 '12 at 00:34
  • OK ... so what about the approaches that you found that aren't thread-like logic? Don't any of them answer your question? Unless you FIX your question to make it more constructive it is likely to get closed ... – Stephen C Dec 17 '12 at 00:56
  • @Stephen C Well yes it does http://code.google.com/p/coroutines/ and as you mentioned http://code.google.com/p/jetlang/ are really close enough implementations. And in a real world scenario these might be enough. My point is to make sure if there is an other way (maybe more low-level) to implement fibers. – Evan P Dec 17 '12 at 01:00
  • Not without changing the JVM - e.g. the first hit! http://weblogs.java.net/blog/forax/archive/2009/11/19/holy-crap-jvm-has-coroutinecontinuationfiber-etc – Stephen C Dec 17 '12 at 01:38

1 Answers1

3

There were/are Java EE frameworks, that enable to have a class with normal control flow like a Java SE application, and thus maintain state. To function over HTTP at specific points the classes instance is serialized, a response is made to the client, and on the next request the instance is deserialized and continues. This is not a general purpose coroutine solution, and I would certainly not call fibers.

Unfortunately its name slips my mind. But that was a specific case of running one single coroutine transfering control to the framework coroutine.

AOP offers another mean to switch control. Could maybe be used to implement fibers.

Joop Eggen
  • 107,315
  • 7
  • 83
  • 138
  • I've never relate AOP to a Fiber implementation. I can think of some close enough solutions but I am not sure if this would be enough to be called as Fibers. – Evan P Dec 17 '12 at 00:57