Answer:
Here is the code:-
//include the required header files
#include<stdio.h>
#include<pthread.h>
// method protocol definition
void *count_lines(void *arg);
int main()
{
  // Create a thread handler
  pthread_t my_thread;
  // Create a file handler
  FILE *fh;
  // declare the variable
  int *linecnt;
  // open the data file
  fh=fopen("data.txt","r");
// Create a thread using pthread_create; pass fh to my_thread;
  pthread_create(&my_thread, NULL, count_lines, (void*)fh);
  //Use pthread_join to terminate the thread my_thread
  pthread_join( my_thread, (void**)&linecnt );
  // print the number of lines
printf("\nNumber of lines in the given file: %d \n\n", linecnt);
  return (0);
}
// Method to count the number of lines
void *count_lines(void *arg)
{
  // variable declaration and initialization
  int linecnt=-1;
  char TTline[1600];
  //code to count the number of lines
  while(!feof(arg))
  {
     fgets(TTline,1600,arg);
     linecnt++;
  }
  pthread_exit((void *)linecnt);
  // close the file handler
  fclose(arg);
}
Explanation:
Program:-