I've been trying to learn about semaphores and thread synchronization by going through some classical problems like producer-consumer problem and dining philosopher's problem.
While reading the solutions of the above problems implemented in C, I've stumbled upon this piece of code segment present in both the solutions
pthread_join(thread_id, NULL);
So as far as I know,
Semaphores are implemented so that only one process can access a part of the program, at a given time
But pthread_join does the same thing, isn't it? It delays the execution of a thread until the other thread has finished execution.
So why add this function even though semaphores are implemented?