From: Rasputin Date: 2004-01-22T07:02:27+09:00 Subject: Re: no timeslicing? Pit Capitain wrote: >> symbols = %w( = ^ V < > @ # ! ) >> threads = [] >> string = "" >> >> symbols.each { |symbol| >> threads << Thread.new(symbol) do |sym| >> 9.times { string << sym } >> end >> } >> >> threads.each { |w| threads.join } >> puts string > > > Maybe Thread.pass can help you. It's also in the pickaxe. > > BTW: shouldn't it be "w.join"? Ack! - just my luck to confuse two completely different methods on two completely different objects that just happen to share a name - thanks! Think the odd output was an artefact of the short duration of each thread - if I add a delay the output is what I'd expect: -------------------------------8<------------------------------ 0rasputin@lb:rasputin$ cvs diff freds.rb Index: freds.rb =================================================================== RCS file: /data/cvsroot/rasputin/freds.rb,v retrieving revision 1.3 diff -r1.3 freds.rb 7c7 < 9.times { string << sym } --- > 9.times { string << sym ; sleep(0.2) } 0rasputin@lb:rasputin$ ruby freds.rb =^V<>@#!!#@>