title: Multithreading - how to stop all threads if condition is met?
body: <p>EDIT : I <strong>cannot</strong> use mutex or sleep() or any type of waiting as we're fairly new to threads in C.</p>
  
  <p>For my assignment I'm to make a <em>bruteforce password cracker</em> using threads. The idea is that I have the hash and salt of a password so I have use a combination of the alphabet A-Z, a-z, 0-9 and encrypt it using the crypt_r function and compare it with the hash and salt I have.</p>
  
  <p>I created 2 threads, one that just checks for lowercase letters and the second one that checks all the letters of the alphabet.</p>
  
  <p>My problem is that once the lowercase thread finds the password it gives it but the second thread continues running in the background.</p>
  
  <p><strong>How can I stop the second thread without using any global variables?</strong></p>
  
  <p>Here's how I go about the thread joins : </p>
  
  <pre><code>for (int i = 0; i &lt; nbThread; ++i) {
      pthread_join(tabThread[i], NULL);
      pthread_join(tabThread2[i], NULL);
  }
  </code></pre>
  
  <p>Thank you for your time and help!</p>