Symbols, Threads and Fibers Flashcards
What is a Symbol in Ruby?
It is an identifier whose value is itself.
How does a Symbol work internally in Ruby?
It is a pointer into Ruby symbol table, that is, Ruby’s internal list.
What is a thread?
It is a little self-contained program that runs inside a bigger program. Technically, the main program runs in a process and that process one or more threads are executed.
In what threat your application runs?
The main thread.
What does the Mutex class do in Ruby?
It implements a simple semaphore that can be used to coordinate access to shared data from multiple concurrent threads.
What is a Fiber in Ruby?
Fibers are workers, they run code and keep track of their own process. In other words, fibers are concurrency mechanisms.
What is the difference between Threads and Fibers?
The start and stop of a Thread are controlled by the Operating System and with the Fibers, we need to tell them exactly when to start and when to stop.
How does the join method work with Threads?
The join method lets a Thread to share time with other Threads but it doesn’t synchronize them.