You use thread join here in the whille loop to tell the main thread there is process thead is running please hold your process so that it will join after execution of processRequest thread.
Here the main thread creates a new thread using pthread_create.
It then waits for this newly created thread to complete by calling pthread_join.
Once the pthread_join call returns, the main thread proceeds to the next iteration of the loop and creates another thread.
This behavior ensures that each thread created by the loop is allowed to complete its execution before another thread is created. As a result, the processRequest function is executed sequentially by different threads, one at a time, rather than concurrently. This can be useful if you want to control the order and synchronization of your threads. If you're experiencing issues without pthread_join, it's likely due to concurrency-related problems in your code.
The concern with using the pthread_join is that it would introduce a form of sequential execution, where one thread has to wait for another, ultimately diminishing the potential for parallelism and concurrent task performance.
However, it's important to note that in the project's context, the requirement is for all the created threads to run concurrently.