I have this piece of code:
puts "Start" loop do Thread.start do puts "Hello from thread" exit end text = gets puts "#{text}" end puts "Done"
What I expect is to see “Start”, followed by “Hello from the stream”, and then I can enter the input that will be returned to me back. Instead, I get "Start" and "Hello from the stream," and then the program exits.
From exit documentation:
Terminates execution and plans to start another thread. If this thread is already marked as dead, exit returns Thread. If this is the main thread or the last thread exits the process.
But I thought I created a new topic? Why does this get out of my main process?
source share