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 where a = putStrLn "a" >> a b = putStrLn "b" >> b
Did you watch it continuously for two hours? It might have changed quicky to "a"s and back again without you noticing. Watch it very carefully. <mischevous grin> :) But seriously, don't waste your time on this example. It just doesn't work too well with GHC, because of the contention between the two threads both trying to access standard output. Cheers, Simon
Actually, my version of the program would halt and print the "SWITCHED!" message if it changed from "a"s to "b"s. But that's ok, I understood why this example won't work well in GHC, but isn't it too disappointing that the "Haskell Concurrent basic example for beginners" is not working well? Andre. ----- Original Message ----- From: Simon Marlow <simonmar@microsoft.com> To: Andre W B Furtado <aw@free.elogica.com.br>; <haskell@haskell.org> Cc: <alms@cin.ufpe.br>; <jeaf@cin.ufpe.br> Sent: Wednesday, April 25, 2001 7:57 AM Subject: RE: running for long enough...
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 where a = putStrLn "a" >> a b = putStrLn "b" >> b
Did you watch it continuously for two hours? It might have changed quicky to "a"s and back again without you noticing. Watch it very carefully. <mischevous grin> :)
But seriously, don't waste your time on this example. It just doesn't work too well with GHC, because of the contention between the two threads both trying to access standard output.
Cheers, Simon
participants (2)
-
Andre W B Furtado -
Simon Marlow