Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] Multithreading vs. Forks


On Sun, Sep 30, 2001 at 09:45:28PM +1000, Ken Foskey wrote:
> Rubbish,  threading is needed in a lot of applications.   For example 
> web servers or even web query utilities so that they can download 
> concurrent parts of the page.

Rubbish, it's not "needed" to do that.  You can do that in single
process by using select(2).  Whether or not that is a faster, easier or
just plain "better" way to do it is a different matter entirely, but
threads aren't necessary to do it.  

> I use threading a bit,   especially for GUI part and application.   
> Splitting these into two threads makes the whole process to work well. 
> Now should the language support this quietly and transparently,  that 
> is a different question.

Definitely.  It all depends on the task at hand.  It's a matter (like
all things) of using the right tool for the job.  Opinions vary on which
solutions are best for which jobs, but there isn't a definite "threads
are always better" or "threads are always worse", despite what some
people claim.  Threads are often a useful tool for GUIs, allowing the UI
to remain responsive while the backend is doing processing without
making life painfully convoluted for the programmer.

I think the answer is "Well, it depends", for almost any question
regarding threads.

-Andrew.