Simple multithreading C project
I agree with commenter @vnp, who says, "The question would greatly benefit from adding getMedianWord code directly. As posted, it is on the verge of being closed as hypothetical." All the interesting stuff is going on in getMedianWord.

TLDR: yep, your use of pthread_create and pthread_join looks fine.

However, I couldn't be sure of that without knowing the declaration of getMedianWord, for which I had to click through to frequency.c:

void *getMedianWord(void *vargp) {
    char *filename = *(char **) vargp;


Okay, this is fine.



However, you could do better by passing the char pointer itself as your void* argument, instead of passing the address of the pointer. That is, if you rewrote your getMedianWord function —

void *getMedianWord(void *vargp) {
    const char *filename = vargp;


— then you could rewrite your main loop correspondingly —

for (int i = 1; i &lt; argc; ++i) {
    pthread_create(&amp;tid[i], NULL, getMedianWord, argv[i]);
}


Notice that I've made two other cosmetic changes here. First, I put braces around every compound statement; see goto fail for why. Second, I took your complicated actual_args/i + 1 logic and turned it into an idiomatic loop running over the half-open range [1, argc). Use the most common idioms you can! It saves your reader some brain cells.

The functional change here is replacing &amp;argv[...] with simply argv[...]. (The cast to void* is not required in C. And likewise the cast back from void* inside getMedianWord is not required in C, although it would be required if you wanted to port this code to C++.)



I won't very closely review the rest of getMedianWord because you didn't post it.

It is definitely not thread-safe, though; there's a data race on file_index. Look up the _Atomic keyword. 



I notice that getMedianWord spends most of its time reading from files, which means that it's not likely to parallelize very well. You'll end up being bounded by the speed of your file-reading. Splitting up those reads into different threads doesn't achieve any speedup; in fact it probably wastes time because now you have to wait for a context-switch between each pair of reads. (OTOH, the files will be buffered at the stdio level and also probably brought into memory at the OS level, so maybe I'm wrong about its hurting. I think I'm right about its not helping, though.)

Try reading all the files into memory first, and then splitting up just the computational processing of those files into multiple threads.

In other words, think of "the filesystem" as a contended resource which will destroy your parallelism if everyone's trying to access it at once. (Also think of the malloc/free heap and stdout as contended resources. Looks like you're doing well on those fronts.)



Your WordArray word_array[MAX_WORDS]; is a variable-length array, which might blow up your (thread's) stack if MAX_WORDS is increased to, say, 2000000 / sizeof(WordArray) — that is, if MAX_WORDS * MAX_STRING &gt;= 2000000. So watch out for that.