<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">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>