title: Thread.join blocks the main thread
body: <p>Calling Thread.join blocks the current (main) thread. However not calling join results in all spawned threads to be killed when the main thread exits. How does one spawn persistent children threads in Ruby without blocking the main thread?</p>
  
  <p>Here's a typical use of join.</p>
  
  <pre><code>for i in 1..100 do
    puts "Creating thread #{i}"
    t = Thread.new(i) do |j|
      sleep 1
      puts "Thread #{j} done"
    end
    t.join
  end
  puts "#{Thread.list.size} threads"
  </code></pre>
  
  <p>This gives  </p>
  
  <pre>     Creating thread 1  
       Thread 1 done  
       Creating thread 2  
       Thread 2 done  
       ...  
       1 threads  
  </pre>
  
  <p>but I'm looking for how to get this  </p>
  
  <pre>
      Creating thread 1  
      Creating thread 2  
      ...  
      101 threads  
      Thread 1 done  
      Thread 2 done  
      ...  
  </pre>
  
  <p>The code gives the same output in both Ruby 1.8.7 and 1.9.2</p>