Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Today I was reading several articles on the Internet about fibers, coroutines and green threads, and it seems like these concepts have very much in common, but there are slight differences, especially when we talk about fibers and coroutines.

Is there a concise, correct summary of what makes them different from each other?

share|improve this question
2  
Did you even try googling? Searching for any two of those terms turns up two Stack Overflow questions (links here and here). –  Doval Aug 22 at 15:05
1  
I saw that thread, but it is not concise. If you take a closer look, the accepted answer says that fibers are the same as coroutines, while the second answer, which I believe is better, says that they are different things. The second link is about thread vs fiber - my question is not about threads. –  DejanLekic Aug 22 at 15:12
8  
@gnat: See below (answered in less than 150 words). –  Robert Harvey Aug 22 at 15:15
1  
@RobertHarvey see above –  gnat Aug 22 at 15:20
2  
@gnat I don't even understand your last comment. Are you saying that because there are two related (but not identical) SO questions already, the new one isn't "reasonably scoped"? –  Kyle Strand Aug 22 at 20:21

1 Answer 1

up vote 50 down vote accepted

A Fiber is a lightweight thread that uses cooperative multitasking instead of preemptive multitasking. A running fiber must explicitly "yield" to allow another fiber to run, which makes their implementation much easier than kernel or user threads.

A Coroutine is a component that generalizes a subroutine to allow multiple entry points for suspending and resuming execution at certain locations. Unlike subroutines, coroutines can exit by calling other coroutines, which may later return to the point where they were invoked in the original coroutine.

A Green Thread is a thread that is scheduled by a virtual machine (VM) instead of natively by the underlying operating system. Green threads emulate multithreaded environments without relying on any native OS capabilities, and they are managed in user space instead of kernel space, enabling them to work in environments that do not have native thread support.

share|improve this answer
    
10  
I can only say for myself - this answer is very valuable to me. I share opinion with Robert on this. –  DejanLekic Aug 22 at 15:16
5  
+1 I hadn't even heard about Green Threads. –  Felix Dombek Aug 22 at 15:17
    
"Summaries of broad topics are specialty of Wikipedia, which is focused and optimized on providing this content and fostering a culture oriented on it. People willing, best capable of and experienced in providing such summaries go to Wikipedia, not to Stack Exchange.... People looking for this in search engine would be typically presented two directly competing content examples, one at SE network, another at Wikipedia... Due to reasons mentioned above, it is most likely that SE content would look inferior in comparison..." –  gnat Aug 22 at 15:39
4  
@gnat Compare/contrast topics are not "broad." They are specifically focused in such a way that Wiki articles are rarely suited for. Yes, the three Wiki articles linked in the answer are helpful for someone trying to understand these three topics, but a concise summary of the topics themselves, juxtaposed so as to quickly show their similarities and differences (which admittedly this answer could do more explicitly), is not something likely to be best done as a Wiki article. –  Kyle Strand Aug 22 at 20:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.