Guest

Untitled

By: a guest on Jan 28th, 2012  |  syntax: None  |  size: 0.29 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. #!/usr/bin/env ruby
  2.  
  3. require 'thread'
  4.  
  5. AllMyLittleThreads = []
  6.  
  7. def foo
  8.   AllMyLittleThreads << Thread.new do
  9.     loop do
  10.       puts "foo"
  11.       foo
  12.     end
  13.   end
  14.   Thread.current.exit
  15. end
  16.  
  17. AllMyLittleThreads << Thread.new { foo }
  18. AllMyLittleThreads.each { |thread| thread.join }