I'm trying to understand Ruby multithreading, and it seems just chaotic. Here's a couple examples I tried:
- Thread never gets executed and program ends
Thread.new do
puts "thread"
end
puts "main"
- Thread is executed but never terminates
thread = Thread.new do
puts "thread"
end
sleep while thread.alive?
puts "main"
- Everything unexpectedly works as expected:
thread = Thread.new do
puts "thread"
end
puts thread.status while thread.alive?
puts "main"
What in Matz' name is going on here?!