Chapter 17. Threads

image with no caption

There may be times when your programs need to perform more than one action at a time. For example, maybe you want to do some disk operations and simultaneously display some feedback to the user. Or you might want to copy or upload some files “in the background” while still allowing the user to carry on with some other task “in the foreground.”

In Ruby, if you want to do more than one task at a time, you can run each task in its own thread. A thread is like a program within a program. It runs some particular piece of code independently of any other threads.

However, as you will see shortly, multiple threads may need to find ways ...

Get The Book of Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.