title: Computing total sum of word frequency by using pthreads in C
body: <p>I am running three threads and trying to computer total frequency of each word.<br>I need put mutex to protect from counting issue.<br></p>
  <pre><code>57848 index is 0
  37389 index is 1
  8447 index is 2
  10016 index is 3
  2756 index is 4
  
  The results are counted as follows : 
  he -&gt; 57848
  she -&gt; 37389
  they -&gt; 8447
  him -&gt; 10016
  me -&gt; 2756
  
  
  
  void threadfunc(char *path, char *filetowrite, long specialfreq[], int num_threads){
  
    DIR* dir = opendir(path);
    if(dir == NULL){ return; }
    struct dirent* entity;
    entity = readdir(dir);
  
    
    for (int i = 0; i &lt; num_threads; i++) {
      if (pthread_join(thread_id[i],  NULL) != 0) {
        perror(&quot;Failed to join thread&quot;);
      }
    }
  }
  </code></pre>