<div dir="ltr">Ok, I&#39;ve figured out my problem - it wasn&#39;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&#39;t allowed.  Tweaking it such that it uses a different name for each fixes the issue.<div>

<br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Aug 4, 2013 at 10:05 PM, Chris Schneider <span dir="ltr">&lt;<a href="mailto:chris@christopher-schneider.com" target="_blank">chris@christopher-schneider.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi, I&#39;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.<div>

<br></div>
<div>The code is here: <a href="https://gist.github.com/cschneid/3862b33c29a803be7848" target="_blank">https://gist.github.com/cschneid/3862b33c29a803be7848</a></div><div><br></div><div>If I launch one thread, or the other (lines 13 &amp; 14), and comment the other one out, it runs as expected.</div>


<div><br></div><div>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 &quot;wins&quot;, and the other never gets to run again.  Most of the time it&#39;s the first one launched that wins, but not always.  See the output for an example.</div>


<div><br></div><div>Adding explicit yield calls, using forkOS vs forkIO, and moving around of where I make the ZMQ context &amp; socket (into and out of the threads) don&#39;t seem to help.</div><div><br></div><div>What am I missing?  How can I get these threads to play nice with each other?</div>


<div><br></div><div>Thanks!</div><div><br></div></div>
</blockquote></div><br></div>