I was just watching top while executing this and noticed that it really only used one core (I am using GHC 6.8.1 on a MacBook). Does anyone know why?
On Nov 28, 2007 10:34 AM, Brad Clow <[EMAIL PROTECTED]> wrote: > If you would like to wait on multiple threads, you can use STM like so: > > import Control.Concurrent > import Control.Concurrent.STM > import Control.Exception > > main = do > tc <- atomically $ newTVar 2 > run tc (print (last [1..100000000])) > run tc (print (last [1..110000000])) > print "Waiting...." > atomically $ readTVar tc >>= \x -> if x == 0 then return () else retry > print "OK." > where > run tc f = forkIO (f `finally` atomReplace (\x -> x - 1) tc) > > atomReplace fn x = atomically $ readTVar x >>= writeTVar x . fn Regards brad -- www.scoodi.com Recycle is good: Reuse is better _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
