Join two threads : join « Threads « Ruby






Join two threads


t1 = Thread.new do
  puts "alpha"
  Thread.pass
  puts "beta"
end
t2 = Thread.new do
  puts "gamma"
  puts "delta"
end

t1.join
t2.join

 








Related examples in the same category

1.each thread is given only one second to execute:
2.Join threads
3.Multithreaded Applications in Ruby
4.rescue the exception at the time the threads are joined.
5.Join a thread after sleeping