add(thread) -> self
[permalink][rdoc]スレッド thread が属するグループを自身に変更します。
puts "Initial group is #{ThreadGroup::Default.list}"
# => Initial group is [#<Thread:0x4a49168 run>]
tg = ThreadGroup.new
t1 = Thread.new { sleep }
t2 = Thread.new { sleep }
puts "t1 is #{t1}" # => t1 is #<Thread:0x50bef60>
puts "t2 is #{t2}" # => t2 is #<Thread:0x50beed0>
tg.add(t1)
puts "Initial group now #{ThreadGroup::Default.list}"
# => Initial group now [#<Thread:0x3039168 run>, #<Thread:0x50beed0 run>]
puts "tg group now #{tg.list}"
# => tg group now [#<Thread:0x50bef60 run>]