[Haskell-cafe] Re: Waiting for thread to finish

david48 dav.vire+haskell at gmail.com
Fri Nov 30 06:44:23 EST 2007


On Nov 28, 2007 11:07 PM, Maurí­cio <briqueabraque at yahoo.com> wrote:

> Sorry, I don't agree. I try to write things in a
> way that when you read it you can get an intuition
> on why it's doing what it's doing; even when the

That's what comment are for :)

> generate. So, instead of checking if threads have
> finished, I decided to check if files exist and
> are available for writing. When I read 'takeMVar

Checking a file is non blocking, right ? So you have to loop until the
file becomes available.
taking a MVar, on the other hand, blocks your thread until the other
one finishes, without using cpu time, etc.

> know of a benchmark where the task is some kind of
> situation where you actually get a result faster
> by using threads than by using a single thread?

Threads won't give you a speedup unless you run the program on a
multi-core/multi-proc machine.
They help making the program simpler, IMHO.


More information about the Haskell-Cafe mailing list