Thread Priorities
So far, I’ve given Ruby total freedom in slicing up the time between threads in any way it wants. But sometimes one thread is more important than the others. For example, if you are writing a file-copying program with one thread to do the actual copying and another thread to display the progress bar, it would make sense to give the file-copying thread most of the time.
Note
There may be times when the currently executing thread specifically wants to give execution time to other threads. This is done by calling the Thread.pass method. However, this may not produce quite the results you expect. The pass method is discussed in more detail in Digging Deeper in Digging Deeper.
Ruby lets you assign integer values to indicate the priority ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access