On 09/02/11 15:34, Krzysztof Skrzętnicki wrote:
Hello Cafe,Here is a simple program that yields strange results: module Main where import Control.Concurrent import Control.Concurrent.Chan import Control.Monad main = do c <- newChan writeChan c 1 forkIO $ forever $ do i <- readChan c print ("forkio",i) isEmptyChan c >>= printNow, this is strange thing: we put single element into the channel. We take it out.
What your program does is put a single element into the channel, and then *repeatedly* try to take one out (notice the forever you have in there!). Judging by the results, the program deadlocks, which seems like a reasonable outcome to me.
Thanks, Neil.
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
