[Haskell-beginners] Threading (lack of) interleaving

Chris Schneider chris at christopher-schneider.com
Mon Aug 5 17:11:04 CEST 2013


Ok, I've figured out my problem - it wasn't threading related at all -
instead it was the second thread dying off due to a ZMQ problem.
 Specifically I was reusing the node name, which apparently isn't allowed.
 Tweaking it such that it uses a different name for each fixes the issue.




On Sun, Aug 4, 2013 at 10:05 PM, Chris Schneider <
chris at christopher-schneider.com> wrote:

> 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/20130805/596740fd/attachment.htm>


More information about the Beginners mailing list