NanoStuff wrote:
> I'm slowly going through the pickaxe, and i've hit the multi-threading
> chapter. Despite all the juicy information, I can't seem to gather what
> the actual benefits of multi-threading on a single processor are.
>
> Is performance improved despite the limitations of one processor, or is
> there a completely performance unrelated purpose to multi-threading that
> I missed entirely?
>
> On another note, how does shared hosting like Dreamhost handle parallel
> processing? (I know this is irrelevant in relation to Ruby's
> multi-threading), but merely for future reference... will the host allow
> your application to use up as many of it's processors as it sees fit, or
> will it simply refuse to run?
>
> Thanks a bunch!
>   

There are two main reasons for using multi-threaded applications, even 
on a single processor:

The first is performance. It's faster to switch between threads than it 
is between processes, and it's (typically) even faster to switch between 
user-level threads like Ruby has. Also, any asynchrony in your program 
(like waiting for input) can be exploited so that you can do another 
task while waiting for something to complete, such as user input, etc.

The second reason is that some programs decompose naturally into 
separate tasks, which can be run in separate threads. This is more of a 
style reason. Threads allow you to modularize code in a way that makes 
sense in a lot of situations.

That's kind of the brief version. Most operating system books would have 
this kind of information.

Hope that helps.

-Justin