T
Tim Pease
$ cat a.rb
t = Thread.new do
while true
puts "printing a line"
sleep 2
end
end
gets
t.exit
puts "exiting"
$ ruby a.rb
printing a line
printing a line
printing a line
printing a line
exiting # after I hit the "Enter" key
This is how it works on Linux and on Cygwin. But when I run the same
code on Windows using the one-click installer ruby, this is what I get
...
exiting # after I hit the "Enter" key
It does not matter how long I let the script run, I'm only getting the
message out of the thread once. It's like the thread never wakes up
again after it goes to sleep.
Is this normal / expected behavior on Windows? Am I missing something obvious?
Blessings,
TwP
t = Thread.new do
while true
puts "printing a line"
sleep 2
end
end
gets
t.exit
puts "exiting"
$ ruby a.rb
printing a line
printing a line
printing a line
printing a line
exiting # after I hit the "Enter" key
This is how it works on Linux and on Cygwin. But when I run the same
code on Windows using the one-click installer ruby, this is what I get
...
printing a lineruby a.rb
exiting # after I hit the "Enter" key
It does not matter how long I let the script run, I'm only getting the
message out of the thread once. It's like the thread never wakes up
again after it goes to sleep.
Is this normal / expected behavior on Windows? Am I missing something obvious?
Blessings,
TwP