title: reading file using multi threads
body: <p>I wanna check a list of ips if they are blacklisted (using multi-threads).</p>
  
  <p>So, I have the following code:</p>
  
  <pre><code>pthread_mutex_t input_queue;
  
  void * process(void * data)
  {
      unsigned long ip = 0xffffffff;
      char line[20];
      while (!feof(INFILE))
      {
          pthread_mutex_lock(&amp;input_queue);//?required
          if (fgets(line,sizeof(line),INFILE) != NULL)
          {
              if (strlen(line) &lt; 8)
                  break;
              if (line[strlen (line) - 1] == '\n')
                  line[strlen (line) - 1] = '\0';
              ip = ntohl((unsigned long)inet_addr(line));
          }
          pthread_mutex_unlock(&amp;input_queue);
          blacklist(ip);
      }
      return NULL;
  }
  
  //in main()
      pthread_mutex_init(&amp;input_queue,NULL);
      for(i = 0 ; i &lt; number_thread; i++)
      {
          if(pthread_create(&amp;thread_id[i],NULL,&amp;process,NULL) != 0)
          {
              i--;
              fprintf(stderr,RED "\nError in creating thread\n" NONE);
          }
      }
      for(i = 0 ; i &lt; number_thread; i++)
          if(pthread_join(thread_id[i],NULL) != 0)
          {
              fprintf(stderr,RED "\nError in joining thread\n" NONE);
          }
  </code></pre>
  
  <p>Is pthread_mutex_lock necessary or fgets is thread safe? I have the feeling that my code has some issues.</p>