Control.Concurrent.Barrier
Documentation
Self-resetting barrier. barrier blocks until a specified
number of threads have reached it, and then they are all allowed to
run. The barrier is then reset so that a further count threads
can block on it. Typical usage is:
do b <- barrier 3
forkIO $ b >> putStrLn "1" -- blocked
forkIO $ b >> putStrLn "2" -- blocked
forkIO $ b >> putStrLn "3" -- all three threads run
Latching barrier. This is the same as barrier, except once the
barrier has opened (the requisite number of threads has reached
it), it remains open, allowing all subsequent threads through
unblocked.