I am trying to create a multithreaded program that will search multiple files from the same directory as the executable line by line for a substring of the phrase "Hello World". Each file is handled by a separate thread.
Unfortunately, the first thread returns 0 for the amount of patterns that are read instead of the correct value, while all other following threads return the correct value. Internally, the thread would show the correct amount of patterns found even for the first thread that returns the wrong value. I just don't understanding why it's returning the incorrect value. Have I misunderstood the way pthread_join()
works?