running for long enough...

Simon Marlow
Wed, 25 Apr 2001 11:57:52 +0100

> About the program below, someone (I think Simon Marlow) said=20
> that if I run
> it for long enough, I'll see "a"s rather than "b"s. I would=20
> 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 =3D forkIO a >> b
> >  where
> >   a =3D putStrLn "a" >> a
> >   b =3D 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
<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.