Ruby multiple background threads

Posted by turri on Stack Overflow See other posts from Stack Overflow or by turri
Published on 2010-05-19T12:52:00Z Indexed on 2010/05/19 13:10 UTC
Read the original article Hit count: 146

Filed under:
|

I need to run multiple background threads in a thread pool with timeout. The scheme is something like:

    #!/usr/bin/env ruby

require 'thread'

def foo(&block)
  bar(block)
end

def bar(block)
  Thread.abort_on_exception=true
  @main = Thread.new { block.call }
end


foo {
sleep 1
puts 'test'
}

Why if i run that i get no output? (and no sleep wait?)

© Stack Overflow or respective owner

Related posts about ruby

Related posts about jruby