# Threads

**URL:** <https://www.ruby-forum.com/t/threads/150860>\
**Category:** Ruby\
**Created:** [October 14, 2008, 10:39am UTC](https://www.ruby-forum.com/t/threads/150860 "2008-10-14T10:39:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phy\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@Phy\_P](https://www.ruby-forum.com/u/Phy_P)\
**Post date:** [October 14, 2008, 10:39am UTC](https://www.ruby-forum.com/t/threads/150860/1 "2008-10-14T10:39:24Z")

</div>

Hello,

So I am new to ruby and have a question about threads. Yes, I  
researched looking for an answer to my question without much luck. I am  
trying to create a bunch of threads that will run forever processing  
numerical information. I wrote a very simple example of what I thought  
would work:

threads = []

list = %w(aS, bS, cS, dS, eS, fS, gS, hS)

for space in list  
threads \<\< Thread.new(space) {|numericalSpace|  
while 1  
puts “#{thread.id}: #{numericalSpace}”  
sleep 2  
end  
}  
end

This does not work as I thought it would, that is it would spin off a  
bunch of threads and every two seconds I would get a thread print the  
simple line to the terminal.

So, what am I missing?

Thanks in advance!  
Phy

---

<div class="post-metadata">

**Author:** ![Phy\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@Phy\_P](https://www.ruby-forum.com/u/Phy_P)\
**Post date:** [October 17, 2008, 8:12am UTC](https://www.ruby-forum.com/t/threads/150860/2 "2008-10-17T08:12:51Z")

</div>

> This does not work as I thought it would, that is it would spin off a  
> bunch of threads and every two seconds I would get a thread print the  
> simple line to the terminal.
> 
> So, what am I missing?

Try adding a Thread.abort\_on\_exception = true to the top.  
Also note that if the “main” thread ever terminates then it kills all  
other threads and ends the program  
Cheers.  
-=R
