R
Rasputin
I decided its high time I tried to learn threads again,
and my best chance is to do it in Ruby.
But the scheduler doesnt seem to want to run any threads
until the previous ones have finished:
------------------8<------------------------
0rasputin@lb:rasputin$ cat freds.rb
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
0rasputin@lb:rasputin$ ruby freds.rb
=========^^^^^^^^^VVVVVVVVV<<<<<<<<<>>>>>>>>>@@@@@@@@@#########!!!!!!!!!
0rasputin@lb:rasputin$
------------------8<------------------------
The pickaxe example at:
http://www.rubycentral.com/book/tut_threads.html#UA
, which is almost identical, seems to timeslice ok.
And if I scatter some magic Thread.pass dust in there it behaves itself.
Is it just that the threads exit too soon to get suspended?
This is on NetBSD 1.6Z with Ruby 1.6.8 and todays CVS.
and my best chance is to do it in Ruby.
But the scheduler doesnt seem to want to run any threads
until the previous ones have finished:
------------------8<------------------------
0rasputin@lb:rasputin$ cat freds.rb
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
0rasputin@lb:rasputin$ ruby freds.rb
=========^^^^^^^^^VVVVVVVVV<<<<<<<<<>>>>>>>>>@@@@@@@@@#########!!!!!!!!!
0rasputin@lb:rasputin$
------------------8<------------------------
The pickaxe example at:
http://www.rubycentral.com/book/tut_threads.html#UA
, which is almost identical, seems to timeslice ok.
And if I scatter some magic Thread.pass dust in there it behaves itself.
Is it just that the threads exit too soon to get suspended?
This is on NetBSD 1.6Z with Ruby 1.6.8 and todays CVS.