Threads

Threads are a powerful tool for creating and maintaining cleaner code, and in many implementations, for making your software more responsive. In Ruby, the former benefit is the one emphasized—cleaner code—since Ruby implements “microthreads.” Microthreads are in-process threads simulated with setjmp/longjmp in the Ruby interpreter itself. Hence, Ruby’s Thread class isn’t dependent on the underlying threads library or operating systems, making Ruby more portable.

Get Ruby in a Nutshell 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.