views:

47

answers:

0

Hello,

I have the exact same problem posted here a year ago: http://stackoverflow.com/questions/1347853/ruby-loop-failing-in-thread

Here the code (pretty much the same as in the topic above)

 class NewObject
    def my_funk
        t = Thread.new {
            until false do
                puts sleep 15 # sleeps way too much
            end
        }
        t.join
  end
end

if __FILE__ == $0
    s = NewObject.new()
    s.my_funk
end

And here is the output:

15
42
36
38
33
45
42
33
32
40

The code basically prints the actual number of seconds slept. Does anyone know what's going on here and how to fix it?

I'm running Windows 7 and Ruby 1.8.7