Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Thread#value

thr.value → obj

Waits for thr to complete, using join, and returns its value or raises the exception which terminated the thread.

Example
a = Thread.new { 2 + 2 }
a.value   #=> 4

b = Thread.new { raise 'something went wrong' }
b.value   #=> RuntimeError: something went wrong
See also #to_s #wakeup #thread_variable_set also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0