[Haskell-cafe] Question on concurrency

Neil Brown nccb2 at kent.ac.uk
Tue Sep 14 06:18:24 EDT 2010


On 14/09/10 07:45, Arnaud Bailly wrote:
>
> What surprised me is that I would expect the behaviour of the two
> functions to be different:
>   - in doRunMvnInIO, I would expect stdout's content to be printed
> before stderr, ie. the 2 threads are ordered because I call takeMVar
> in between calls to forkIO
>   - in doRunMvnInIO', this is not true and both theads run concurrently.
>
> but actually there does not seem to be a difference: printing is still
> interleaved in both functions, AFAICT.
>
>    
Hi,

I've tried your code (substituting a program that spits out different 
streams of numbers on stdout and stderr for maven), and I see the 
behaviour you had expected: the first version does print all of stdout 
before stderr, whereas the second version shows interleaving of the two 
streams.  Are you certain that you are seeing interleaving in the first 
version?

Thanks,

Neil.



More information about the Haskell-Cafe mailing list