Jetlang's fibers are not really fibers?

Skip to first unread message

Magnus Holm

Feb 20, 2012, 9:00:59 AM2/20/12
Hey folks,

It seems to me that Jetlang's fibers really aren't fibers at all. The whole of fibers is that they can be suspended/resumed in the middle of a code block. Jetlang's fibers are more like a channel where you publish Runnables, and there's thread that automatically pulls stuff from the channel and runs it.

Did I misunderstand something, or is this the case?

peter royal

Feb 20, 2012, 10:09:31 AM2/20/12
you have accurately described how jetlang works. 

java doesn't let you achieve what 'fiber' means in other programming contexts exactly. however, I think it's behavior is a reasonable approximation (and suspend/resume could be implemented with the boundary between Runnable's being the valid pause points). 


peter royal - (on the go)
You received this message because you are subscribed to the Google Groups "jetlang-dev" group.
To view this discussion on the web visit
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Winter Young

Dec 13, 2015, 2:36:14 AM12/13/15
to jetlang-dev
So this means if I blocked in a runnable, the backing thread would block, like akka, right?

Mike Rettig

Dec 13, 2015, 12:12:11 PM12/13/15
Jetlang is a lightweight java library. It doesn't change how threads
works in the jvm. If code executes that blocks on I/O then the thread
blocks. However, that choice is up to the developer. There are plenty
of non-blocking api's available if you don't want your thread to
block. With fibers, the easy solution is to replace the blocking call
with a channel publish. Another fiber can subscribe and process the
events asynchronously, even blocking if necessary.

If you want lightweight threads, then maybe pool fibers might be
better. Each ThreadFiber is backed by an OS thread. If it is a pool
fiber, then the fiber doesn't block a thread when it is awaiting work.
All runnables are executed by the threads in the configured thread
pool. The pool fibers are simple objects (no thread creation), so they
are lightweight and scale well. ThreadFibers and pool fibers can be
used in the same app.

> To unsubscribe from this group and stop receiving emails from it, send an
> email to
> To post to this group, send email to
> Visit this group at
> For more options, visit
Reply all
Reply to author
0 new messages