Joel VanderWerf wrote:

> Paul Lutus wrote:
>> ara.t.howard / noaa.gov wrote:
>> 
>>> threads.each{|t| t.join}
>> 
>> In my expereince, if you join all the spawned threads to the current
>> thread, this guarantees that they will run sequentially. They will
>> certainly run, which is a good thing, but they won't run concurrently.
>> 
>> BTW I am not saying this about threads in general, I am saying it about
>> Ruby threads.
> 
> This seems concurrent to me, or did you mean something different:
> 
> threads = (0..9).map {|i| Thread.new {sleep rand(5); puts i}}
> threads.each {|t| t.join}
> 
> __END__
> 
> Output:
> 
> 4
> 8
> 9
> 0
> 7
> 5
> 2
> 1
> 6
> 3

I tried to think of an explanation apart from the obvious one, but it seems
I am wrong. I think the fact that they are all sleeping their time away may
partly explain this outcome, but the threads are clearly running
concurrently.

Threads that are not sleeping may not live up to the promise of this
example. My threads tend not to run concurrently, but your example is an
excellent refutation.

-- 
Paul Lutus
http://www.arachnoid.com