Why four threads, and not say, five, or three? (Is this a homework problem??)
The thread function you have, print_message_function(), does not appear to be doing too much, other than printing a message to standard out. I thought that you had other requirements: counting words, counting characters, etc.
It seems to me that it might be worthwhile to implement threads that perform each of the tasks that are required. Of course, a single-thread could do it all.
Anyhow, consider opening your files, one at a time, and starting three threads to accomplish the activities that you require. Each thread returns a "count" of something; consider returning this either via the passed in arg to the thread, or via the thread's return value. You can obtain the thread's return value using the pthread_join() function.
Good luck (with the homework).
|