 <p>You're passing a zero to <code>pthread_join</code> as the thread you want to join:</p> <pre><code>pthread_join(0,NULL); </code></pre> <p>You wanted:</p> <pre><code>pthread_join(threads[0],NULL); pthread_join(threads[1],NULL); </code></pre> <p>You have several other bugs though. For one thing, your <code>checkOdd</code> code calls <code>pthread_cond_wait</code> even when it's that thread's turn.</p> <p>You don't seem to understand condition variables. Specifically, you seem to think that somehow the condition variable will know whether or not the thing you are waiting for has happened. It does not -- condition variables are stateless. It's your job to keep track of what you're waiting for and whether or not it has happened.</p>