
27 Nov
2007
27 Nov
'07
11:32 a.m.
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