briqueabraque:
> Hi,
>
> After I have spawned a thread with
> 'forkIO', how can I check if that
> thread work has finished already?
> Or wait for it?
The usual trick I use is to have an MVar that child thread can set when
done, causing the main thread to wait:
main = do
done <- newEmptyMVar
forkIO (fibonacci done)
takeMVar done -- blocks till MVar is full
print "All done"
fibonacci = do
... do some work ..
putMVar done () -- ok, main thread can finish now
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe