Recall & Review
beginner
What is a Fiber in Ruby?
A Fiber is a lightweight concurrency tool in Ruby that allows you to pause and resume code execution manually, enabling cooperative multitasking.
Click to reveal answer
intermediate
How does Fiber differ from Thread in Ruby?
Fibers are cooperative, meaning they yield control explicitly, while Threads are preemptive and managed by the Ruby scheduler. Fibers are lighter and do not run in parallel.
Click to reveal answer
beginner
What method is used to start or resume a Fiber?
The
Fiber#resume method is used to start or continue execution of a Fiber from where it last yielded.Click to reveal answer
beginner
What does
Fiber.yield do?Fiber.yield pauses the current Fiber and returns control to the caller, allowing cooperative multitasking.Click to reveal answer
intermediate
Why is Fiber considered cooperative concurrency?
Because Fibers only switch control when they explicitly yield, unlike threads which can be interrupted at any time by the scheduler.
Click to reveal answer
Which method starts or resumes a Fiber in Ruby?
✗ Incorrect
Fiber#resume is the correct method to start or continue a Fiber.What happens when
Fiber.yield is called?✗ Incorrect
Fiber.yield pauses the Fiber and returns control to the caller, enabling cooperative multitasking.Fibers in Ruby are best described as:
✗ Incorrect
Fibers require explicit yielding, so they are cooperative concurrency units.
Which of the following is NOT true about Fibers?
✗ Incorrect
Fibers do not run in parallel; they run cooperatively on a single thread.
What is the main advantage of using Fibers?
✗ Incorrect
Fibers provide efficient cooperative multitasking with less overhead than threads.
Explain how Fibers enable cooperative concurrency in Ruby.
Think about how Fibers pause themselves and let others run.
You got /4 concepts.
Describe the difference between Fibers and Threads in Ruby.
Consider how control is passed in Fibers vs Threads.
You got /4 concepts.