From: Phy Prabab Date: 2008-10-14T17:48:18+09:00 Subject: Re: Threads Never mind, I resolved the issue by reading a bit more. Sorry to waste the thread. Cheers, Phy --- On Tue, 10/14/08, Phy Prabab wrote: > From: Phy Prabab > Subject: Threads > To: ruby-talk@ruby-lang.org > Date: Tuesday, October 14, 2008, 4:31 AM > 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