On 02.07.2008 18:29, barjunk wrote:
> OK, I'm going to try to recap what I learned so far from reading links
> and making some assumptions (*bad*):
> 
> 1 - Green threads are threads that run in user space.

Native threads do this as well.  The difference between native and green 
threads is who does the scheduling: native threads are scheduled by the 
OS's scheduler and can use all cores available in a system.  Green 
threads are scheduled by a piece of user code (from the OS's perspective).

> 2 - Forking allows for running multiple ruby interpreters, each with
> their own memory space.

Correct.

> 3 - Ruby provides a thread mechanizm, but these threads are
> serialized.

Yes.  Ruby's threads are green threads.  I would not call them 
"serialized" though because that sounds like one complete thread was 
executed after the other.  However, even with green threads they appear 
to execute concurrently although no two threads can simultaneously be 
active.

> 4 - Native threads are used in Jruby, and in Ruby 1.9 YARV

JRuby yes.  I am not sure about 1.9 - I believe native threads are not 
yet completely supported there.

> 5 - If you use ruby threads, each thread shares the memory space of
> all the others.

This is true for both thread models.  Actually this is one of the core 
differences between threads and processes: since multiple threads can 
use the same process space they automatically share memory.  Processes 
are separate by default and can only share memory explicitly via 
operating system specific means.

> Hopefully I hit on all the major points that were made.

Not exactly but for the most part. :-)

>  It looks like
> forking is what I'm looking for in my use case:
> 
>  - I want sandboxing for each 'thread'
>  - I don't want one 'thread' to block another
> 
> Thanks for the discussion guys.  Seems like there is more to be
> learned though.

I always recommend Doug Lea's book - although it specifically deals with 
Java I find the general mechanisms very well explained - and those apply 
to other PL as well.

http://www.amazon.com/dp/0201310090

Kind regards

	robert