The Main Thread

Even if you don’t explicitly create any threads, there is always at least one thread executing—the main thread in which your Ruby program is running. You can verify this by entering the following:

thread_main.rb

p( Thread.main )

This will display something like this:

#<Thread:0x28955c8 run>

Here, Thread is the thread’s class, 0x28955c8 (or some other number) is its hexadecimal object identifier, and run is the thread’s current status.

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.