Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Threading (lack of) interleaving (Chris Schneider)


----------------------------------------------------------------------

Message: 1
Date: Sun, 4 Aug 2013 22:05:47 -0600
From: Chris Schneider <ch...@christopher-schneider.com>
To: beginners@haskell.org
Subject: [Haskell-beginners] Threading (lack of) interleaving
Message-ID:
        <CAGHc4ujW1UZJcM6JeZMn-zQ_d00p3hMPpFcNcgbhw-g_H=0...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi, I'm working on a program that should launch, spawn two threads, each
with a zeromq connection, where those threads ping the zmq channel
repeatedly.  The main thread just sits and waits.

The code is here: https://gist.github.com/cschneid/3862b33c29a803be7848

If I launch one thread, or the other (lines 13 & 14), and comment the other
one out, it runs as expected.

But if I attempt to launch both, both build themselves, and run one call of
themselves, but then it seems that one or the other thread "wins", and the
other never gets to run again.  Most of the time it's the first one
launched that wins, but not always.  See the output for an example.

Adding explicit yield calls, using forkOS vs forkIO, and moving around of
where I make the ZMQ context & socket (into and out of the threads) don't
seem to help.

What am I missing?  How can I get these threads to play nice with each
other?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130804/cb5c86c9/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 62, Issue 2
****************************************

Reply via email to