running for long enough...
Andre W B Furtado
Thu, 19 Apr 2001 02:00:17 -0300
About the program below, someone (I think Simon Marlow) said that if I run
it for long enough, I'll see "a"s rather than "b"s. I would like to know for
how long I will have to wait, since 2 hours were not enough to see it
switching from "b"s to "a"s.
> main = forkIO a >> b
> a = putStrLn "a" >> a
> b = putStrLn "b" >> b
----- Original Message -----
From: Tom Pledger <Tom.Pledger@peace.com>
Sent: Tuesday, April 17, 2001 12:24 AM
Subject: Concurrent Haskell (Ops...)
> Andre W B Furtado writes:
> | import Concurrent
> | main :: IO()
> | main = let loop ch = putStr(ch) >> loop ch in
> | forkIO (loop "a") >> loop "z"
> | But this program prints only 'z's, and no 'a's. I was surprised by
> | this, since GHC uses preemptive multitasking, not cooperative
> | multitasking. Does anyone knows what's going wrong?
> By my count, this is now a TAQ (thrice asked question). :-)
> Haskell mailing list